akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public Main() {
		// TODO 自動生成されたコンストラクター・スタブ
	}
	
	public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			// 整数の入力
			int a;
			int b,n;
			String result;
			a = sc.nextInt();
			b = sc.nextInt();
			n = sc.nextInt();
			if (a>b) {
				if(a>n && n>b) {
					result="Yes";
					}
				else{
					result="No";
					}
				}
			else if(a<b){
				if(a<n && n<b) {
					result="Yes";
					}
				else{
					result="No";
					}
				}
			else{
					if(a==n ) {
						result="Yes";
						}
					else{
						result="No";
						}
				}
			// 出力

			System.out.println(result);
	}
}

Measured memory_bytes: 22996
#include <iostream>

using namespace std;

int main()
{

    int x,y,i,j,X,Y,W,H,D,N,count;
    
    cin >> D;
    
    for(i=0;i<D;i++){
        count = 0;
        cin >> X >> Y >> W >> H;
        cin >>N;
        for(j=0;j<N;j++){
            cin >> x >> y;
            if((X<=x)&&(x<=(X+W))){
                if((Y<=y)&&(y<=(Y+H))){
                    count++;
                }
            }
        }
        cout << count << endl;
    }
    
    return 0;
}

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



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    
    ll n;
    cin>>n;
    ll ans = n/2;
    if(n%2==0) ans--;
    cout << ans << endl;
    
}

Measured memory_bytes: 256
//⣿⣿⣿⣿⣿⣿⠟⠋⠁⣀⣤⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⣿⣿
//⣿⣿⣿⣿⠋⠁⠀⠀⠺⠿⢿⣿⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠻⣿
//⣿⣿⡟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣤⣤⣤⣤⠀⠀⠀⠀⠀⣤⣦⣄⠀⠀
//⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣶⣿⠏⣿⣿⣿⣿⣿⣁⠀⠀⠀⠛⠙⠛⠋⠀⠀
//⡿⠀⠀⠀⠀⠀⠀⠀⠀⡀⠀⣰⣿⣿⣿⣿⡄⠘⣿⣿⣿⣿⣷⠄⠀⠀⠀⠀⠀⠀⠀⠀
//⡇⠀⠀⠀⠀⠀⠀⠀⠸⠇⣼⣿⣿⣿⣿⣿⣷⣄⠘⢿⣿⣿⣿⣅⠀⠀⠀⠀⠀⠀⠀⠀
//⠁⠀⠀⠀⣴⣿⠀⣐⣣⣸⣿⣿⣿⣿⣿⠟⠛⠛⠀⠌⠻⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀
//⠀⠀⠀⣶⣮⣽⣰⣿⡿⢿⣿⣿⣿⣿⣿⡀⢿⣤⠄⢠⣄⢹⣿⣿⣿⡆⠀⠀⠀⠀⠀⠀
//⠀⠀⠀⣿⣿⣿⣿⣿⡘⣿⣿⣿⣿⣿⣿⠿⣶⣶⣾⣿⣿⡆⢻⣿⣿⠃⢠⠖⠛⣛⣷⠀
//⠀⠀⢸⣿⣿⣿⣿⣿⣿⣾⣿⣿⣿⣿⣿⣿⣮⣝⡻⠿⠿⢃⣄⣭⡟⢀⡎⣰⡶⣪⣿⠀
//⠀⠀⠘⣿⣿⣿⠟⣛⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⡿⢁⣾⣿⢿⣿⣿⠏⠀
//⠀⠀⠀⣻⣿⡟⠘⠿⠿⠎⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣵⣿⣿⠧⣷⠟⠁⠀⠀
//⡇⠀⠀⢹⣿⡧⠀⡀⠀⣀⠀⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠋⢰⣿⠀⠀⠀⠀
//⡇⠀⠀⠀⢻⢰⣿⣶⣿⡿⠿⢂⣿⣿⣿⣿⣿⣿⣿⢿⣻⣿⣿⣿⡏⠀⠀⠁⠀⠀⠀⠀
//⣷⠀⠀⠀⠀⠈⠿⠟⣁⣴⣾⣿⣿⠿⠿⣛⣋⣥⣶⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⣿⡀ 
//
//⣿⠛⣷⠀⠀⢸⣟⡛⠀⠀⣿⠛⣷⠀⠀⢸⣟⡛⠀⠀⣴⢟⣛⡀⠀⠀⣸⢿⣇⠀ 
//⣿⠉⠉⠀⠀⢸⣯⣥⠀⠀⣿⠉⠉⠀⠀⢸⣯⣥⠀⠀⢿⣮⣽⡇⠀⢠⡿⠶⣿⡄ 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define DEBUG false
#define debugf if (DEBUG) printf
#define MAXN 1000010
#define MAXM 900009
#define MAXLOGN 20
#define ALFA 256
#define MOD 998244353
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define EPS 1e-9
#define PI 3.141592653589793238462643383279502884
#define FOR(x,n) for(int x=0; (x)<int(n); (x)++)
#define FOR1(x,n) for(int x=1; (x)<=int(n); (x)++)
#define REP(x,n) for(int x=int(n)-1; (x)>=0; (x)--)
#define REP1(x,n) for(int x=(n); (x)>0; (x)--)
#define pb push_back
#define pf push_front
#define pr printf
#define sc(x) scanf(" %d", &x)
#define sc2(x, y) sc(x);sc(y)
#define sc3(x, y, z) sc2(x, y);sc(z)
#define scll(x) scanf(" %lld", &x)
#define sc2ll(x, y) scll(x);scll(y)
#define sc3ll(x, y, z) sc2ll(x, y);scll(z)
#define ff first
#define ss second
#define mp make_pair
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define mset(x,y) memset(&x, (y), sizeof(x))
#define LOWBIT(A) (A & -A)
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned int uint;
typedef vector <int> vi;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef pair < pll, ll > plll;
template <class T>
	using ord_set = tree<T, null_type, less<T>, rb_tree_tag,
	tree_order_statistics_node_update>;

vector <ii> Test[16];
int n;

bool testar(int mask){
    for(int i = 0; i < n; i++){
        if((1 << i) & mask){
            FOR(j, sz(Test[i])){
                bool verd = (1 << (Test[i][j].ff - 1)) & mask;
                if( verd ^ (Test[i][j].ss > 0)) return false;
            }
        }
    }
    return true;
}
int main(){
    sc(n);
    FOR(i, n){
        int a;sc(a);
        FOR(j, a){
            int u, v;
            sc2(u, v);
            Test[i].push_back({u, v});
        }
    }
    int bestResp = 0;
    for(int i = 0; i < (1 << n); i++){
        if(testar(i)){
            bestResp = max(bestResp, (int)__builtin_popcount(i));
        }
    }
    pr("%d\n", bestResp);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

minv = 0
maxv = 1000000000

nxt = [0] * (n + 1)
for i in range(n):
  nxt[i+1] = a[i] * 2 - nxt[i]

ans = [0] * (n + 1)
ans[0] = nxt[n] // 2

for i in range(n):
  ans[i+1] = a[i] * 2 - ans[i]
    
for i in range(n):
  print(ans[i], end=' ')

Measured memory_bytes: 64868
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
void RatingGoal() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b) {
		cout << c << endl;

	}
	else if (a == c) {
		cout << b << endl;

	}
	else {
		cout << a << endl;

	}
}
int main() {

	RatingGoal();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[200005],n;
bool b[200005];
inline bool pd(int x){
	for(int i=1;i<=n*2-1;i++) b[i]=(a[i]>=x);
	b[0]=b[1];
	for(int i=n;i<=n+n-1;i++){
		if(b[i]==b[i+1]) return b[i];
		if(b[n+n-i]==b[n+n-i-1]) return b[n+n-i];
	}
	return b[1];
}
int main(){
	cin>>n;
	for(int i=1;i<=n*2-1;i++) cin>>a[i];
	int l=1,r=n*2,ans=0;
	while(l<=r){
		int md=(l+r)/2;
		if(pd(md)) l=md+1,ans=max(ans,md); 
		else r=md-1;
	}
	cout<<ans;
}

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

struct StQuery
{
  StQuery() : m_nLeft(0), m_nRigt(0) { }

  int m_nLeft;
  int m_nRigt;
};

void fnInput(string& rsStr, vector<StQuery>& rvoQuery)
{
  int nStrSiz, nQuerySiz;
  cin >> nStrSiz >> nQuerySiz;
  rvoQuery.resize(nQuerySiz);

  cin >> rsStr;
  
  for (StQuery& roQuery : rvoQuery)
    cin >> roQuery.m_nLeft >> roQuery.m_nRigt;
}

void fnSubStrACCnt(string sStr, const vector<StQuery>& cnrvoQuery)
{
  vector<int> vnCumlSum(sStr.size() + 1);      // 累積和

  for (int nBgn = 0; nBgn < vnCumlSum.size() - 1; nBgn++)
  {
    vnCumlSum[ nBgn + 2 ] = vnCumlSum[ nBgn + 1 ];
    if (sStr[nBgn] == 'A' && sStr[nBgn + 1] == 'C')
      vnCumlSum[ nBgn + 2 ] = vnCumlSum[ nBgn + 1] + 1;
  }

  //累積和index 0 1 2 3 4 5 6 7 8
  //文字列       A C A C T A C G
  //文字列位置   1 2 3 4 5 6 7 8
  for (int i = 0; i < cnrvoQuery.size(); i++)
  {
    cout << vnCumlSum[ cnrvoQuery[i].m_nRigt ] - vnCumlSum[ cnrvoQuery[i].m_nLeft ];
    cout << endl; 
  }
}
 
int main()
{
  string sStr;
  vector<StQuery> voQuery;

  fnInput(sStr, voQuery);
  fnSubStrACCnt(sStr, voQuery);

  return 0;
}

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

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    for (int i=0; i<s.size(); ++i) {
        if (s[i] + n > 'Z') s[i] = s[i] - 26 + n;
        else s[i] = s[i] + n;
    }
    cout << s;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

int main(){
    int n,a,b;
    cin>>n>>a >>b;
    cout << min(n*a,b)<< endl;

}



Measured memory_bytes: 256
from collections import defaultdict

n, k = map(int, input().split())
a = list(map(int, input().split()))
cnt = defaultdict(int)
for i in range(n):
    cnt[a[i]] += 1

cnt = sorted(cnt.items(), key = lambda x:x[1])
ans = 0
for i in range(len(cnt) - k):
    ans += cnt[i][1]
print(ans)



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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const int N = 200007, M = 1e9 + 7;

ll memo[N];
ii v[N];

ll fat[N];

ll fast_pow(ll a, ll b) {
	ll ans = 1;
	while(b) {
		if(b&1) ans = ans * a % M;
		b >>= 1;
		a = a * a % M;
	}
	return ans;
}

ll calc(ll L, ll R) {
	return fat[L + R] * fast_pow(fat[L] * fat[R] % M, M - 2) % M;
}

int n;

ll solve(int pos) {
	ll & st = memo[pos];
	if(st == -1) {
		int r, c; tie(r, c) = v[pos];
		st = calc(r-1, c-1);
		for(int i = 0; i < n; i++) {
			if(i == pos) continue;
			int p, q; tie(p, q) = v[i];
			if(p <= r and q <= c) {
				st = (st - (solve(i) * calc(r - p, c - q) % M) + M)%M;
			}
		}
	}
	return st;
}

int main() {
	memset(memo, -1, sizeof memo);
	ios::sync_with_stdio(0); cin.tie(0);

	fat[0] = 1;
	for(int i = 1; i < N; i++) {
		fat[i] = fat[i-1] * i % M;
	}

	int h, w; cin >> h >> w >> n;

	for(int i = 0; i < n; ++i) {
		int r, c; cin >> r >> c;
		v[i] = ii(r, c);
	}

	ll ans = calc(h-1, w-1);
	for(int i = 0; i < n; i++) {
		int p, q; tie(p, q) = v[i];
		ans = (ans - (solve(i) * calc(h - p, w - q) % M) + M)%M;

	}
	cout << ans << endl;
}


Measured memory_bytes: 4480
# import sys
# input = sys.stdin.readline

def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))

n,m = mp()
class UnionFind():
    def __init__(self, n):
        # uf.parentsで各ノードの親をリストで返す
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        # uf.find(x)で処理を行う
        #　要素xが属するグループの根を返す（経路圧縮）
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        # uf.union(x,y)で処理を行う
        # 要素xが属するグループと要素yが属するグループを併合する
        # 小さい部分木を大きい部分木にくっつける
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        # uf.size(x)で処理を行う
        # 要素xが属するグループの要素数を返す
        return -self.parents[self.find(x)]

    def same(self, x, y):
        # uf.same(x,y)で処理を行う
        # 要素x,yが同じグループに属するかどうかを返す
        return self.find(x) == self.find(y)

    def members(self, x):
        # uf.members(x)で処理を行う
        # 要素xが属するグループに属する要素をリストで返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        # uf.roots()で処理を行う
        #　すべての根の要素をリストで返す
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        # uf.group_count()で処理を行う
        # グループの数を返す
        return len(self.roots())

    def all_group_members(self):
        # all_group_members()で処理を行う
        # 極力使わないこと
        # ｛ルート要素：[グループに属する要素のリスト]｝をdict型で返す
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        # ルート要素：[グループに属する要素のリスト]を文字列で返す
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
uf = UnionFind(n)
# nodeは0-indexedにすることに注意
for i in range(m):
    a,b = mp()
    uf.union(a-1, b-1)
print(uf.group_count()-1)



Measured memory_bytes: 73776
while True:
    h, w = map(int, input().split())
    if w+h == 0:
        break
    for y in range(h):
        line = ""
        for x in range(w):
            if (y+x) % 2 == 0:
                line += "#"
            else:
                line += "."
        print(line)
    print()



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

int main()
{
  int x = 0;
  int y = 0;
  while(1)
  {
    cin >> x;
    cin >> y;
    
    if(x == 0 && y == 0)
    	break;
  	if (x > y)
    	cout << y << " " << x << endl;
  	else if (x < y)
    	cout << x << " " << y << endl;
    else if (x == y)
  		cout << x << " " << y << endl;
  }
  return(0);
}


Measured memory_bytes: 3016
N, M = map(int, input().split())
H = list(map(int,input().split()))

C = []

for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] > H[B-1]:
        C.append(B)
    elif H[A-1] < H[B-1]:
        C.append(A)
    else:
        C.append(A)
        C.append(B)

C = set(C)
ans = N - len(C)
print(ans)

Measured memory_bytes: 19992
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int MAX=2e5+10;



int main(){
	int N,Q;
	cin>>N>>Q;
	int S[MAX],T[MAX],X[MAX];
	rep(i,N)cin>>S[i]>>T[i]>>X[i];
	int D[MAX];
	rep(i,Q)cin>>D[i];
	
	vector<tuple<int,int,int>> ev;
	rep(i,N){
		ev.push_back(make_tuple(S[i]-X[i],1,X[i]));
		ev.push_back(make_tuple(T[i]-X[i],-1,X[i]));
	}
  	sort(ev.begin(),ev.end());
	
	
    multiset<int> st;
	int now=0;
  	int l=sz(ev);
  	
	rep(i,Q){
		while(get<0>(ev[now])<=D[i] && now<l){
			if(get<1>(ev[now])==1){
				st.insert(get<2>(ev[now]));
			}
			
			if(get<1>(ev[now])==-1){
				st.erase(get<2>(ev[now]));
			}
			now++;
		}
		if(st.empty()){
			cout<<-1<<endl;
		}
		else{
			int z=*st.begin();
			cout<<z<<endl;
		}
	}
}

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

using namespace std;

using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl

template <typename T> T gcd(T m, T n) {
  if (m < n)
    return gcd(n, m);
  if (n == 0)
    return m;
  return gcd(n, m % n);
}
int main() {
  IN(N); IN(M);


  string S, T;
  cin >> S >> T;

  REP(i, M) {
    ll j = (ll)i * N;
    if (j % M == 0) {
      j /= M;
      if (T[i] == S[j])
        continue;
      OUT(-1);
      return 0;
    }
  }
  ll L = (ll)N * M;
  L /= gcd(N, M);
  OUT(L);


  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
set<int> con;
int main()
{
	int n,x;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if(con.find(x)!=con.end())
		    con.erase(con.find(x));
		else
		    con.insert(x);
	}
	printf("%d\n",con.size());
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
set<int > ss;
int main()
{
	for(int i='a';i<='z';i++) ss.insert(i);
		string s;
	cin>>s;
	int len=s.length();
	for(int i=0;i<len;i++){
		if(ss.count(s[i])) ss.erase(s[i]);
	}
	if(!ss.empty()) printf("%c\n",*(ss.begin()));
	else printf("None\n");
	return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
#define REP(i, x, y) for(ll i = x; i < y; i++)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

ll dp[5010][5010];

int main() {
    ll N;
    cin >> N;
    tiii T[N];
    REP(i, 0, N) {
        ll h, p;
        cin >> h >> p;
        T[i] = make_tuple(h + p, h, p);
    }
    sort(T, T + N);
    REP(i, 0, 5010) {
        fill(dp[i], dp[i] + 5010, inf);
    }
    dp[0][0] = 0;
    REP(i, 1, N + 1) {
        dp[i][0] = 0;
        REP(j, 1, i + 1) {
            dp[i][j] = dp[i - 1][j];
            if (get<1>(T[i - 1]) >= dp[i - 1][j - 1]) {
                dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + get<2>(T[i - 1]));
            }
        }
    }
    ll ans = 0;
    REP(i, 0, N + 2) {
        if (dp[N][i] == inf) {
            ans = i - 1;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 196480
import math
 
h,w = list(map(int, input().split()))
data = []
for i in range(h):
    a=list(map(str, input().split()))
    data.append(a[0])

hlist=[]
wlist=[]
for i in range(h):
    flag=0
    for j in range(w):
        if(data[i][j]=='#'):
            flag=1
    if(flag==1):
        hlist.append(i)

for i in range(w):
    flag=0
    for j in range(h):
        if(data[j][i]=='#'):
            flag=1
    if(flag==1):
        wlist.append(i)
        

for i in range(len(hlist)):
    temp=""
    for j in range(len(wlist)):
        temp+=data[hlist[i]][wlist[j]]
    print(temp)

Measured memory_bytes: 3064
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int W = stdIn.nextInt();
		int H = stdIn.nextInt();
		
		int[] listx = new int[W+1];
		int[] listy = new int[H+1];
		
		for(int i = 0; i < N; i++) {
			int x = stdIn.nextInt();
			int y = stdIn.nextInt();
			int w = stdIn.nextInt();
			listx[Math.max(0, x-w)]++;
			if(x + w + 1 <= W)  {
				listx[x+w]--;
			}
			
			listy[Math.max(0, y-w)]++;
			if(y + w + 1 <= H) {
				listy[y+w]--;
			}
		}
		boolean ans1 = true;
		boolean ans2 = true;
		if(listx[0] == 0) ans1 = false;
		if(listy[0] == 0) ans2 = false;
		for(int i = 1; i < W+1; i++) {
			listx[i] += listx[i-1];
			if(listx[i] == 0) {
				ans1 = false;
			}
		}
		for(int i = 1; i < H+1; i++) {
			listy[i] += listy[i-1];
			if(listy[i] == 0 || ans1) {
				ans2 = false;
			}
		}
		System.out.println((ans1||ans2)?"Yes":"No");
		
		
	}
}

Measured memory_bytes: 98176
function main(_stdin) {
    const stdin = _stdin.trim().split('\n');
    const [n, k] = stdin.shift().split(' ').map(Number);
    const w = stdin.map(Number);

    let left = 0;
    let right = w.reduce((t, c) => t += c);

    if(k > 1) {
        while (right - left > 1) {
            const mid = Math.floor((left + right) / 2);

            if (n <= getBagNumWhenCapaIs(mid, k, w)) {
                right = mid;
            } else {
                left = mid;
            }
        }
    }
    console.log(k === 0 ? 0 : right);
}

function getBagNumWhenCapaIs(mx, numTrucks, bags) {
    let bagIdx = 0;
    for (let j = 0; j < numTrucks; j++) {
        let curWeight = 0;
        while (curWeight + bags[bagIdx] <= mx) {
            curWeight += bags[bagIdx];
            bagIdx++;
            if (bagIdx === bags.length) {
                return bags.length
            }
        }
    }
    return bagIdx;
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));




Measured memory_bytes: 32416
n = int(input())
a = []
for _ in range(n):
    a.append(int(input())-1)

v = [False]*n
v[0] = True

ans = 0
tmp = 0

while tmp != 1:
    ans += 1
    tmp = a[tmp]
    if v[tmp]:
        print(-1)
        exit()
    else:
        v[tmp] = not v[tmp]

print(ans)


Measured memory_bytes: 13776
n,k,q = map(int,input().split())
scr = [k-q for _ in range(n)]
for _ in range(q):
  a = int(input()) - 1
  scr[a] += 1
for i in range(n):
  if scr[i] > 0:
    print('Yes')
  else:
    print('No')

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

vector<ll> A, K;

ll dfs(ll A, ll K) {
  if (A<K) return 0;
  else {
    if (A%K==0) return A/K;
    else {
      ll diff = A - A/K*K;
      ll count = (diff+A/K) / (A/K+1);
      // cout << diff <<  " " << count << endl;
      return dfs(A-count*(A/K+1), K);
    }
  }
}

int main() {
  int N; cin >> N;
  A.resize(N); K.resize(N); rep(i,N) cin >> A[i] >> K[i];
  ll G[N]; rep(i,N) G[i] = dfs(A[i], K[i]);
  // debug(G,G+N);
  ll xsum = 0; rep(i,N) xsum ^= G[i];
  string result = xsum ? "Takahashi" : "Aoki";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) (V).begin(),(V).end()
#define MOD 1000000007
#define mod 998244353

int main(){
	ll S, C;
	cin >> S >> C;
	if (S * 2 > C) {
		cout << C / 2 << endl;
	}
	else {
		C -= S * 2;
		cout << S + C / 4 << endl;
	}
}

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

int N;
const int MAX_N = 1.0e5 + 100;
int H[MAX_N];


int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> H[i];

    bool is_ok = true;
    for (int i = 0; i < N-1; i++) {
        if (H[i] - H[i+1] > 1) {
            is_ok = false;
            break;
        }
        else if (H[i] - H[i+1] == 1) {
            H[i+1]++;
        }
    }

    cout << (is_ok ? "Yes" : "No") << endl;    

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;
#define ll long long 


struct fenwick{
  int lim;
  long long int *tree;
  fenwick(int _lim){
      lim=_lim;
      tree=new long long int[lim];
  }
  void init(){
    for(int i=0;i<lim;i++){
      tree[i]=0;
    }
  }
  void update(int x,long long int v){
    while(x<lim){
      tree[x]+=v;
      x+=x&(-x);
    }
  }
  long long int query(int x){
    long long int ans=0;
    while(x>0){
      ans+=tree[x];
      x-=x&(-x);
    }
    return ans;
  }
  int _query(int k){
    int low=1;
    int high=500000;
    int ans=0;int x=k;
    while(low<=high){
      int mid=low+(high-low)/2;
      if(query(mid)>=x){
        ans=mid;
        high=mid-1;
      }else{
        low=mid+1;
      }
    }
    return ans;
  }
};

int main()
{
  ll n; 
  cin>>n;
  ll mm[100005];
  memset(mm,0,sizeof(mm));
  ll sum=0;
  ll ans=0;
  for(int i=0;i<n;++i){
  	ll x; cin>>x;
  	mm[x]++;
  	ans+=x;
  }
  int q; cin>>q;
  while(q--){
  	ll b,c; cin>>b>>c;
  	if(mm[b]==0){
  		cout<<ans<<endl;
  		continue;
  	}
  	ll pp=mm[b];
  	ans=ans+c*pp-b*pp;
  	mm[c]+=pp;
  	mm[b]=0;
  	cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 4412
from math import *

a, b, c = map(int, input().split())
d = 0

if a * b / 2 >= c / a:
    d = atan(a * b * b / (2 * c)) * 180 / pi
else:
    y = 2 * c / (a * a) - b
    d = atan((b - y) / a) * 180 / pi

print("%.8f" % d)

Measured memory_bytes: 3060
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include<set>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define DIVCEIL(a,b) ((a+b-1)/b)
//int CHMAX

int intpow(int a, int n) {
	// a^nのint ver
	rep(i, n - 1)
		a *= a;
	return a;
}
int MODPOW(int a, int n, int mod) {
	// a^n mod
	int ans = 1;
	while (n > 0) {
		if (n & 1)
			ans = ans * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return ans;
}
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int MODFACT(int a, int mod) {
	if (a == 0)
		return 1;
	else
		return (a * FACT(a - 1)) % mod;
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
int MODnPr(int n, int r, int mod) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++) {
		sum *= i;
		sum = sum % MOD;
	}
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return  a * b / GCD(a, b);
}
int NUMOFDIV(int n) {
	//約数の数（だっけ？）
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
int CEIL1(int n) {
	//1桁目切り上げ
	return (n + 9) / 10 * 10;
}
int DIGIT(int n, int k) {
	//nのk桁目
	rep(i, k - 1)
		n /= 10;
	return n % 10;
}
int DIGITSUM(int n) {
	int sum = 0, dig;
	while (n) {
		dig = n % 10;
		sum += dig;
		n /= 10;
	}
	return sum;
}
int DIVTIME(int n, int k) {
	//nをkで何回割れるか的な
	int div = 0;
	while (n % k == 0) {
		div++;
		n /= k;
	}
	return div;
}
int binary(int n) {
	//10進数→2進数
	int ans = 0;
	for (int i = 0; n > 0; i++) {
		ans += n % 2 * intpow(10, i);
		n /= 2;
	}
	return ans;
}
int intabs(int n) {
	if (n < 0)
		return -1 * n;
	else
		return n;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool between(int x, int min, int max) {
	if (min < x && x < max)
		return true;
	else
		return false;
}
inline bool PRIMEOR(int x) {
	if (x == 1)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}
bool SQRTOR(int n) {
	if (sqrt(n) == (int)sqrt(n))
		return true;
	else
		return false;
}
// 順位付け
using namespace std;
#pragma endregion

signed main() {
	int K, ans = 0;
	cin >> K;
	REP(i, K) {
		REP(j, K) {
			REP(k, K) {
				int x;
				x = GCD(i, j);
				x = GCD(x, k);
				ans += x;
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;

int n,a[100];

void dfs(int p,int lim){
	if(p==n+1){
		for(int i=1;i<=n;i++){
			cout<<char(a[i]+'a'-1);
		}
		cout<<endl;
		return;
	}
	for(int i=1;i<=lim;i++){
		a[p]=i;
		dfs(p+1,lim+(i==lim));
	}
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	dfs(1,1);
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int main() {
  int N;
  cin>>N;
  
  vector<string> S(N);
  set<string> st;
  for(int i=0;i<N;++i){
    cin>>S[i];
    st.insert(S[i]);
  }
  
  cout<<st.size()<<endl;
}


Measured memory_bytes: 25076
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define N 2*10e5
#define precise cout<<fixed<<setprecision(10)
#pragma GCC optimize("O0")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#define rep(i,a,b) for(int i=a;i<b;i++)
#define min3(a,b,c) min(a,min(b,c))
#define nl cout<<"\n";
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define mod 1000000007
typedef long long ll;
typedef vector<long long> vl;
typedef vector<pair<long,long>> vp;
void get(ll arr[],ll n){for(ll i=0;i<n;i++) cin>>arr[i];}
ll gcd(ll a,ll b);
ll binpow(ll a,ll b);
set<ll> s[200001];
ll vis[200001]={0};
ll n,m,siz=0;
void dfs(ll i)
{
    vis[i]=1;
    siz++;
    for(auto &x: s[i])
    {
        if(vis[x]==0) dfs(x);
    }
}
void solve()
{
    ll n,m;
    cin>>n>>m;
    ll a,b;
    rep(i,0,m)
    {
        cin>>a>>b;
        s[a].insert(b);
        s[b].insert(a);
    }
    set<ll> v;
    rep(i,1,n+1)
    {
        if(vis[i]==0)
        {
            siz=0;
            dfs(i);
            v.insert(siz);
        }
    }
    auto it=v.end();
    it--;
    cout<<*it;
}
int main()
{
 	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
	 	solve();
	}
	//cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}
ll binpow(ll a, ll b) {
   ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

Measured memory_bytes: 39548
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x, y;
    cin >> x >> y;
    cout << (ll)(log2((long double)y / (long double)x)) + 1 << endl;
    
    return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize(2)
#pragma G++ optimize(2)

#include <bits/stdc++.h>

#define LL long long
#define int long long
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<LL, LL>
#define pdd pair<double, double>
#define fastio ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define length(p1, p2) ((p1.fi-p2.fi)*(p1.fi-p2.fi)+(p1.se-p2.se)*(p1.se-p2.se))
#define ith(state, i) (state & (1 << i))
#define PI acos(-1.0)
#define SZ(x) ((int)(x.size()))

using namespace std;

constexpr int N = 2e5+9;
constexpr int M = 1e6+7;
constexpr int INF = 0x3f3f3f3f3f3f3f3f;
constexpr int INF2 = 0xcfcfcfcfcfcfcfcf;

int h, w, k;
int r1, c1, r2, c2;
const static vector<pii> dirs = {{0, 1}, {0, -1}, {-1, 0}, {1, 0}};

int upRound(int x) {
    return x / k * k + (!!(x % k)) * k;
}

signed main() {
    fastio
    cin >> h >> w >> k;
    vector<vector<vector<int>>> dis(h+1, vector<vector<int>>(w+1, vector<int>(4, INF)));
    vector<vector<char>> a(h+1, vector<char>(w+1, 0));
    cin >> r1 >> c1 >> r2 >> c2;
    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++)
            cin >> a[i][j];
    auto cmp = [&dis](const pair<pii, int>& p1, const pair<pii, int>& p2) {
        if (dis[p1.fi.fi][p1.fi.se][p1.se] != dis[p2.fi.fi][p2.fi.se][p2.se])
            return dis[p1.fi.fi][p1.fi.se][p1.se] < dis[p2.fi.fi][p2.fi.se][p2.se];
        return p1 < p2;
    };
    set<pair<pii, int>, decltype(cmp)> s(cmp);
    for (int d = 0; d < 4; d++)
        dis[r1][c1][d] = 0,
        s.emplace(pii{r1, c1}, d);
    while (!s.empty()) {
        auto p = *s.begin();
        s.erase(s.begin());
        pair<pii, int> p2;
        for (int d = 0; d < 4; d++) {
            p2.fi.fi = p.fi.fi + dirs[d].fi;
            p2.fi.se = p.fi.se + dirs[d].se;
            p2.se = d;
            if (p2.fi.fi < 1 || p2.fi.fi > h) continue;
            if (p2.fi.se < 1 || p2.fi.se > w) continue;
            if (a[p2.fi.fi][p2.fi.se] == '@') continue;
            int ndis = d == p.se ? dis[p.fi.fi][p.fi.se][p.se] + 1 : upRound(dis[p.fi.fi][p.fi.se][p.se]) + 1;
            if (ndis < dis[p2.fi.fi][p2.fi.se][p2.se]) {
                s.erase(p2);
                dis[p2.fi.fi][p2.fi.se][p2.se] = ndis;
                s.insert(p2);
            }
        }
    }
    int ans = INF;
    for (int d = 0; d < 4; d++)
        ans = min(ans, upRound(dis[r2][c2][d]) / k);
    cout << (ans > h * w ? -1 : ans) << endl;
    return 0;
}

Measured memory_bytes: 214136
#include <stdio.h>
#include <stdlib.h>

int main()
{
    long long n,k,i,j,index,out[200001]={0},output;
    long long a[200001]={0};
    int flag=0,repeat=0;
    scanf("%lld %lld",&n,&k);
    for(i=1;i<=n;i++){
        scanf("%lld",&a[i]);
    }
    for(i=1;i<=k;i++){
        if(i==1){
            output = a[1];
            out[i] = a[1];
            a[1] = -out[1];
            index = out[i];

        }
        else{
            output = a[index];
            out[i] = a[index];
            a[index] = -out[i];
            index = out[i];
        }        

        if(output<0){
            for(j=1;j<i;j++){
                if((-out[i])==out[j]){
                    repeat = i-j;                    
                    flag = 1;
                    break;
                }
            }
        }
        if(flag==1){
            index = (k-j)%repeat;
            output = out[j+index];
            break;
        }


    }
    printf("%lld\n",output);
    return 0;
}


Measured memory_bytes: 4860
def main():
        N,Q = map(int,input().split())
        ab = [list(map(int,input().split())) for _ in range(N - 1)]
        ab.sort()
        
        plus = [0 for _ in range(N)]
        for _ in range(Q):
        	p,x = map(int,input().split())
        	plus[p - 1] += x 

        for a,b in ab:
                plus[b - 1] += plus[a - 1]
        print(*plus)

if __name__ == '__main__':
        main()

Measured memory_bytes: 67276
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.nextInt();
		int max = 0;
		int maxTmp = 0;
		int before = 0;
		while (sc.hasNextInt()) {
			int input = sc.nextInt();
			if (before >= input) {
				maxTmp++;
			} else {
				maxTmp = 0;
			}
			if (max < maxTmp) {
				max = maxTmp;
			}
			before = input;
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 59428
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end() 

int const N = 200001;
int n;
vector<int> v;

int main(){
    scanf("%d", &n);
    for(int i = 0,x; i<n; ++i){
        scanf("%d", &x);
        v.push_back(x);
    }
    sort(all(v));
    int mx = min(v[0], v[1]-v[0]);
    pair<int,int> an = {v[1], v[0]};
    for(int i = 0; i<n; ++i){
        int k = upper_bound(all(v), (v[i] + 1 >> 1))-v.begin();
        --k; 
        if(k < 0)continue;
        if(min(v[k], v[i] - v[k]) >= mx)mx = min(v[k],v[i]-v[k]), an = {v[i], v[k]};
        ++k;
        if(k == i || k >= n)continue;
        if(min(v[k], v[i] - v[k]) >= mx)mx = min(v[k],v[i]-v[k]), an = {v[i], v[k]};        
    }
    printf("%d %d\n", an.first, an.second);
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7,N=2e5+5;
int n,m,k;
ll f[N],invf[N];
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
void init()
{
    f[0]=invf[0]=1;
    for(int i=1;i<=200000;i++)
        f[i]=f[i-1]*i%mod,invf[i]=qpow(f[i],mod-2);
}
ll c(int n,int m)
{
    return f[n]*invf[n-m]%mod*invf[m]%mod;
}
ll solve(int n,int m,int k)
{
    ll ans=0;
    for(int i=1;i<n;i++)
        ans=(ans+c(n*m-2,k-2)*(n-i)%mod*m%mod*m%mod*i%mod)%mod;
    return ans;
}
int main()
{
    init();
    scanf("%d%d%d",&n,&m,&k);
    printf("%lld\n",(solve(n,m,k)+solve(m,n,k))%mod);
}


Measured memory_bytes: 3328
/* ex4_1
   moka223711 */

#include <stdio.h>

int main(void){
    // n本の木があり、1〜nの番号がついている
    // 番号iの木に監視員がつき、i-dからi+dまでの木を監視できる
    // すべての木を監視するのに必要な監視員の数の最小値を求める
    
    int n, d, ans = 0;
    scanf("%d %d", &n, &d);
    
    // 監視員はi-dからi+dまでの2d+1本の木を監視できる
    // nを2d+1で割った商を求め、余りがあったときはもう一人監視員を加える
    
    ans = n / (2*d + 1);
    if(n % (2*d + 1) != 0){
        ans++;
    }
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>

using namespace std;

int N, T, A;
float min_temp = 100000;
int min_index = 0;
float ave_temp;

int main()
{
  cin >> N;
  cin >> T >> A;
  int H[N];
  for (int i=0; i<N; i++) {
    cin >> H[i];
  }
  for (int i=0; i<N; i++) {
    ave_temp = T - 0.006 * float(H[i]);
    float diff = abs(float(A) - ave_temp);
    if(diff < min_temp) {
      min_temp = diff;
      min_index = i;
    }
  }
  cout << min_index+1 << endl;
  return 0;
}


Measured memory_bytes: 256
N, T = map(int, input().split())

min_cost = 1001
for _ in range(N):
    c, t = map(int, input().split())
    if T < t:
        continue

    min_cost = min(min_cost, c)

if min_cost <= 1000:
    print(min_cost)
else:
    print('TLE')


Measured memory_bytes: 2940
<?php

fscanf(STDIN, "%s", $s);

switch ($s) {
    case 'SUN':
        echo 7;
        break;
    case 'MON':
        echo 6;
        break;
    case 'TUE':
        echo 5;
        break;
    case 'WED':
        echo 4;
        break;
    case 'THU':
        echo 3;
        break;
    case 'FRI':
        echo 2;
        break;
    case 'SAT':
        echo 1;
        break;
}



Measured memory_bytes: 4604
def calc(num_1, op, num_2):
    if op == '+':
        print(num_1 + num_2)
    elif op == '-':
        print(num_1 - num_2)
    elif op == '*':
        print(num_1 * num_2)
    else :
        print(int(num_1 / num_2))

flag = True
while flag == True:
    info = input().split()
    num_1 = int(info[0])
    op = info[1]
    num_2 = int(info[2])
    if op == '?':
        flag = False
        break
    else :
        calc(num_1, op, num_2)


Measured memory_bytes: 5600
def solve():
    A, B, C = [int(x) for x in input().split()]
    if A == B and not A == C:
        return 'Yes'
    if A == C and not A == B:
        return 'Yes'
    if B == C and not A == B:
        return 'Yes'
    else:
        return 'No'

if __name__ == '__main__':
    print(solve())


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

int main(){
    int a, b, c, divisors = 0;
    cin >> a >> b >> c;
    for (int i = a; i <= min(b, c); i++) {
        if (c % i == 0) {
            divisors++;
        }
    }
    cout << divisors << endl;
    return 0;
}


Measured memory_bytes: 3096
#include <stdio.h>

main(){
  int n, pm, pe, pj, i;

  while(1){
    scanf("%d", &n);
    if(n==0) break;
    for(i=0;i<n;i++){
      scanf("%d %d %d", &pm, &pe, &pj);
      
      if(pm==100 || pe==100 || pj==100) printf("A\n");
      else if((pm+pe)>=180) printf("A\n");
      else if((pm+pe+pj)>=240) printf("A\n");
      else if((pm+pe+pj)>=210) printf("B\n");
      else if((pm+pe+pj)>=150 && (pm>=80 || pe>=80)) printf("B\n");
      else printf("C\n");
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
 
  string sa,sb,sc;
  cin>>sa>>sb>>sc;

  char turn ='a';
  char winner;

  while(1){

    if(turn == 'a'){
      if(!sa.empty()){
        turn=sa.front();
        sa.erase(0,1);
      }
      else{
        winner='a';
        break;
      }
    }else if(turn == 'b'){
      if(!sb.empty()){
        turn=sb.front();
        sb.erase(0,1);
      }
      else{
        winner='b';
        break;
      }
    }else if(turn == 'c'){
      if(!sc.empty()){
        turn=sc.front();
        sc.erase(0,1);
      }
      else{
        winner='c';
        break;
      }
    }
  }

  if(winner=='a')
    cout<<'A'<<endl;
  else if(winner=='b')
    cout<<'B'<<endl;
  else if(winner=='c')
    cout<<'C'<<endl;

  return 0;
}

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

int main() {
  int N, d;
  cin >> N;
  int squ = 0, sum=0, ans = 0;
  for (int i=0; i < N; i++) {
    cin >> d;
    sum += d; squ += d * d;
  }
  cout << (sum * sum - squ) / 2 << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0;i < n;i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        if (n%2==0) {
            for (int i = 0;i < n;i++) {
                if (i/2*2+1!=a[i]) {
                    System.out.println(0);
                    return;
                }
            }
        } else {
            if (a[0]!=0) {
                System.out.println(0);
                return;
            }
            for (int i = 1;i < n;i++) {
                if ((i+1)/2*2!=a[i]) {
                    System.out.println(0);
                    return;
                }
            }
        }
        int c = n/2;
        int ret = 1;
        for (int i = 0;i < c;i++) {
            ret = ret*2%1000000007;
        }
        System.out.println(ret);
    }
}


Measured memory_bytes: 33324
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;


vector<int> g[10];
int visit[10];
int ans, n, m;

void f(int v, int cnt) {
    //printf("v = %d, cnt = %d\n", v, cnt);
    if (cnt == n) {
        ans++;
        return;
    }
    
    
    for (int i = 0; i < g[v].size(); i++) {
        if (visit[g[v][i]] == false ) {
            visit[g[v][i]] = true;
            f(g[v][i], cnt+1);
            visit[g[v][i]] = false;
        }
    }
}


int main() {
    ios::sync_with_stdio(false);
    
    cin >> n >> m;
    
    
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    
    visit[1] = true;
    f(1, 1);
    cout << ans << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll int64_t 
#define f(i,s,e) for(i=s;i<e;++i)
#define endl << "\n"
#define sp << " "
#define INF INFINITY
#define mset(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI acos(-1) 
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define eb(a) emplace_back(a)
#define print(x) for(auto it:x) cout<<it<<' '; cout<<"\n";

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;

int main()
{
	FAST_IO ;
	ll i,j,k,n,h,w,m;
	cin >> h >> w >> m;
	vector <ll> row_count(h,0),col_count(w,0) ;
	vector < pair <ll,ll> > vec(m) ;
	ll max_r = 0,max_c = 0;
	f(i,0,m)
	{
		cin >> j >> k ;
		j-- ; k-- ;
		row_count[j]++ ; col_count[k]++ ;
		max_r = max(max_r,row_count[j]) ; max_c = max(max_c,col_count[k]) ;
		vec[i] = {j,k} ;
	}
	ll count_maxr = 0, count_maxc = 0,count = 0;
	f(i,0,h)
		if(row_count[i]==max_r)
			count_maxr++ ;
	f(i,0,w)
		if(col_count[i]==max_c)
			count_maxc++ ;
	f(i,0,m)
		if(row_count[vec[i].F]==max_r && col_count[vec[i].S]==max_c)
			count++ ;
	if(count==(count_maxr*count_maxc))
		cout << max_r + max_c - 1 endl;
	else
		cout << max_r + max_c endl ;
	return 0;
}

/*
If u haven't come up with an approach yet ,skip this one
  Try this when feeling stuck -
  1. Int overflow, array bounds
  2. Special cases (n=1?)
  3. Prove your approach to yourself(mathematical induction,counter-intuitive or stronger test cases)
  4. Calm down and don't look at standings and stop thinking about rating and think about the question
  5. Just do it! 
*/ 

//Benq's advice - 
/* 
	And following advices are must for me -
	* do something instead of nothing and stay organized
	* WRITE STUFF DOWN 
*/

//#define _GLIBCXX_DEBUG 
// It will convert WA verdict to runtime error if that error is caused due to out of bound excess , declare it at the top
//#pragma GCC optimize "trapv" 
// It will convert WA to runtime error if WA was caused due to int overflow error,declare it anywhere

Measured memory_bytes: 12700
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

using i8 = ::std::int_least8_t;
using i32 = ::std::int_least32_t;
using i64 = ::std::int_least64_t;
using u8 = ::std::uint_least8_t;
using u32 = ::std::uint_least32_t;
using u64 = ::std::uint_least64_t;
using isize = ::std::ptrdiff_t;
using usize = ::std::size_t;

class rep {
	const usize f, l;

public:
	class itr {
		friend rep;
		usize i;
		itr(usize x) noexcept : i(x) {}

	public:
		void operator++() noexcept { ++i; }
		usize operator*() const noexcept { return i; }
		bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	rep(usize first, usize last) noexcept : f(first), l(last) {}
	itr begin() const noexcept { return itr(f); }
	itr end() const noexcept { return itr(l); }
};
class revrep {
	const usize f, l;

public:
	class itr {
		friend revrep;
		usize i;
		itr(usize x) noexcept : i(x) {}

	public:
		void operator++() noexcept { --i; }
		usize operator*() const noexcept { return i; }
		bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	revrep(usize first, usize last) noexcept : f(first), l(last) {}
	itr begin() const noexcept { return itr(l - 1); }
	itr end() const noexcept { return itr(f - 1); }
};
template <class T> bool maxi(T &a, const T &b) {
	return a <= b ? (a = b, 1) : 0;
}
template <class T> bool mini(T &a, const T &b) {
	return b <= a ? (a = b, 1) : 0;
}
template <class T> bool smaxi(T &a, const T &b) {
	return b <= a ? 0 : (a = b, 1);
}
template <class T> bool smini(T &a, const T &b) {
	return a <= b ? 0 : (a = b, 1);
}
template <class T> using vec_alias = ::std::vector<T>;
template <class T> auto md_vec(usize n, const T &value) {
	return ::std::vector<T>(n, value);
}
template <class... Args> auto md_vec(usize n, Args... args) {
	return ::std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> const T &as_const(const T &v) noexcept { return v; }

#include <algorithm>
#include <iostream>
#include <utility>
#include <string>
#include <stack>

int main() {
	u32 n, m;
	::std::string s;
	::std::cin >> n >> m >> s;
	::std::vector<::std::vector<u32>> g(n * 2);
	while (m--) {
		u32 a, b;
		::std::cin >> a >> b;
		--a;--b;
		if (s[a] == s[b]) {
			g[a].emplace_back(b + n);
			g[b].emplace_back(a + n);
		}
		else {
			g[a + n].emplace_back(b);
			g[b + n].emplace_back(a);
		}
	}
	::std::vector<u32> deg(n * 2, 0);
	for (const auto &v:g) {
		for (const auto j : v) {
			++deg[j];
		}
	}
	::std::stack<u32> st;
	for (const auto i : rep(0, n * 2)) {
		if (!deg[i])
			st.push(i);
	}	

	while (!st.empty()) {
		const auto v = st.top();
		st.pop();
		for (const auto u : g[v]) {
			--deg[u];
			if (!deg[u])
				st.push(u);
		}
	}
	for (const auto d : deg) {
		if (d) {
			::std::cout << "Yes" << ::std::endl;
			return 0;
		}
	}
	::std::cout << "No" << ::std::endl;
	return 0;
}


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

int main(){
    while(1){
        int n,r;
        cin >> n >> r;
        if(n==0) break;
        
        vector<int> deck(n);
        for(int i=0; i<n; i++){
            deck[i] = n-i;
        }
        
        for(int i=0; i<r; i++){
            int p,c;
            cin >> p >> c;
            vector<int> tmp(c);
            for(int j=0; j<c; j++){
                tmp[j] = deck[p+j-1];
            }
            for(int j=p-2; j>=0; j--){
                deck[j+c] = deck[j];
            }
            for(int j=0; j<c; j++){
                deck[j] = tmp[j];
            }
        }
        cout << deck[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 3076