akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)

int in() { int x; scanf("%d", &x); return x; }
template<typename T> void pv(T a, T b) { for (T i = a; i < b; i++) cout << *i << ' '; cout << endl; }
template<typename T, typename U> void chmin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> void chmax(T &x, U y) { if (x < y) x = y; }

int abs(int a, int b) {
  int c = a - b;
  return c <= 0 ? -c : c;
}

int main() {
  int N = in();

  int ct = 0, cx = 0, cy = 0;
  REP(i,N) {
    int t = in(), x = in(), y = in();
    int diff = t - ct;
    int distance = abs(x, cx) + abs(y, cy);

    bool reachable = false;
    if (diff % 2 == 0 && distance % 2 == 0) {
      reachable = true;
    } else if (diff % 2 != 0 && distance % 2 != 0) {
      reachable = true;
    } else {
      reachable = false;
    }

    if (diff < distance) {
      cout << "No" << endl;
      return 0;
    }
    if (!reachable) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}



Measured memory_bytes: 256
import java.util.*;

// Tenakaichi 2017-D
// http://tenka1-2017.contest.atcoder.jp/tasks/tenka1_2017_d	

public class Main {

	public static void main (String[] args) throws InterruptedException {
		Scanner in = new Scanner(System.in);

		int N = in.nextInt();
		int K = in.nextInt();

		int[] nums = new int[N];
		int[] values = new int[N];
		
		for (int i = 0; i < N; i++) {
			nums[i] = in.nextInt();
			values[i] = in.nextInt();
		}
		
		long answer = 0;
				
		for (int i = -1; i < 32; i++) {
			if (i == -1 || ((1 << i) & K) > 0) {
				long tempAnswer = 0;
				for (int j = 0; j < N; j++) {
					if (i == -1 || (nums[j] & (1 << i)) == 0) {
						boolean shouldAdd = true;
						for (int k = i + 1; k < 32; k++) {
							if ((K & (1 << k)) == 0 && (nums[j] & (1 << k)) > 0) {
								shouldAdd = false;
								break;
							}
						}
						
						if (shouldAdd) {
							tempAnswer += values[j];
						}
					}
				}
				answer = Math.max(answer, tempAnswer);
			}
		}
		System.out.println(answer);
	}
}


Measured memory_bytes: 89532
N=int(input())
*A,=map(int,input().split())
*B,=map(int,input().split())

if sum(A)<sum(B):
  print(-1)
  exit()
  
#A,B = map(sorted,(A,B))

res=0
count=0
for i in range(N):
  if B[i]>A[i]:
    res += B[i]-A[i]
    count += 1
    
if count==0:
  print(0)
  exit()
  
plus = [A[i]-B[i] for i in range(N) if A[i]>B[i]]
plus = sorted(plus,reverse=True)

for i in range(len(plus)):
  res -= plus[i]
  count += 1
  if res<=0:break
    
print(count)

Measured memory_bytes: 24276
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N; string S;
	cin >> N >> S;
	vector<int> sum(N + 1);
	for (int i = 0; i < N; ++i) {
		sum[i + 1] = sum[i] + (S[i] == '#' ? 1 : 0);
	}
	int ans = N;
	for (int i = 0; i <= N; ++i) {
		ans = min(ans, sum[i] + (N - i) - (sum[N] - sum[i]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1412
n = gets
s = gets.chomp.split.map(&:to_i)
q = gets
t = gets.chomp.split.map(&:to_i).sort!
 
c = 0
y = s.shift
t.each{|x|
    y = s.shift while y && y < x
    break unless y
    c += 1 if y == x
}
puts c

Measured memory_bytes: 18440
n,k = map(int,input().split())
p_list = list(map(int,input().split()))

max_count = 0
summary = 0
 
for i in range(n-k+1):
    if i == 0:
        summary = sum(p_list[i:i+k])
    else:
        summary += p_list[i+k-1]-p_list[i-1]
    max_count = max(max_count,summary)
 
print(max_count/2 + k/2)

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

using ll = long long int;
using ull = unsigned long long int;
using P = pair<int, int>;
using P3 = pair<P,ll>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = 998244353;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr double EPS = 1e-9;

int main(){
    int N, S;
    cin >> N >> S;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    ll ans = 0;
    vector<vector<ll> > dp(N+1, vector<ll>(S+1));
    dp[0][0] = 1;
    for(int i=0;i<N;i++){
        for(int j=0;j<=S;j++){
            if(j<S) dp[i+1][j] = dp[i][j];
            if(j>=a[i]){
                if(j==a[i]) dp[i+1][j] += i+1;
                else dp[i+1][j] += dp[i][j-a[i]];
            }
            dp[i+1][j] %= MOD;
        }
    }
    for(int i=0;i<=N;i++){
        ans += dp[i][S]*(N-i+1);
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
struct Point { double x, y; };
inline void koch(int n, Point a, Point b) {
	if (n == 0) return;
	Point s, t, u;
	double th = M_PI / 3.0;
	s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
	s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
	t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
	t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
	u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
	u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
	koch(n - 1, a, s);
	cout << s.x << " " << s.y << endl;
	koch(n - 1, s, u);
	cout << u.x << " " << u.y << endl;
	koch(n - 1, u, t);
	cout << t.x << " " << t.y << endl;
	koch(n - 1, t, b);
}
int main() {
	cout << setprecision(8) << fixed;
	int n; cin >> n;
	Point a = { 0, 0 }, b = { 100, 0 };
	cout << a.x << " " << a.y << endl;
	koch(n, a, b);
	cout << b.x << " " << b.y << endl;
	return 0;
}

Measured memory_bytes: 3204
# -*- coding: utf-8 -*-
# モジュールのインポート
import numpy as np

# 標準入力を取得
D = int(input())
c = list(map(int, input().split()))
s = []
for d in range(D):
    s_d = list(map(int, input().split()))
    s.append(s_d)
t = []
for d in range(D):
    t_d = int(input())
    t.append(t_d)

c = np.array(c)
s = np.array(s)
t = np.array(t)

# 求解処理
KIND = 26
last = np.array([0 for i in range(KIND)])
S = 0
for d in range(1, D + 1):
    S += s[d - 1][t[d - 1] - 1]
    last[t[d - 1] - 1] = d
    S -= sum(c * (d - last))
    print(S)


Measured memory_bytes: 27424
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

long long N, A[1 << 18];

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

	long long s = -A[N - 1];
	for (int i = 0; i < N; i++) s += 2LL * A[i];
	for (int i = 0; i < N; i++) {
		s -= A[i / 2];
	}
	cout << s << endl;
	return 0;
}

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

int main() {
	int a, b, c, d, e, f;
	for (int i = 0; i < 3; i++) {
		int ans = 0;
		int suma = 0, sumb = 0;
		cin >> a >> b >> c;
		cin >> d >> e >> f;
		suma = 3600 * a + 60 * b + c;
		sumb = 3600 * d + 60 * e + f;
		if (suma < sumb) ans = sumb - suma;
		else ans = suma + sumb;
		int h = 0, m = 0, s = 0;
		h = ans / 3600;
		ans = ans - ans / 3600 * 3600;
		m = ans / 60;
		ans = ans - ans / 60 * 60;
		s = ans;
		printf("%d %d %d\n", h, m, s);
	}
	return 0;
}

Measured memory_bytes: 3144
#include<stdio.h>
int main() {
    long i, count = 0, ans = 0;
    char s[222222];
    for (i = 0; i < 222222; i++)
        s[i] = '\0';
    scanf("%s", s);
    i = 0;
    while (s[i]!='\0'){
        if (s[i] == 'B')
            count++;
        else
            ans += count;
i++;
    }
    printf("%ld\n", ans);
    return 0;
}


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

void startup()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

int32_t main()
{
    startup();
	
		 int n;
		 cin>>n;
		 string s;
		 cin>>s;

		 int cntw=0;
		 int cntr=0;
		 for(int i=0 ; i<n ; ++i)
		 {
		 	if(s[i]=='W')
		 		cntw++;
		 	else
		 		cntr++;
		 }
		 	int ans=0;
		 	for(int i=cntr-1 ; i>=0 ; --i)
		 	{
		 		if(s[i]=='W')
		 			++ans;
		 	}
		 	cout<<ans;
		 

    return 0;
}




Measured memory_bytes: 3724
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
LL A[100000];

LL ans = 0;

void solve(){
	LL prev_index = -INF;
	for(int i=0;i<N;i++){
		if(A[i]%2==0){
			ans += A[i]/2;
			if(prev_index!=-INF && A[i]!=0) prev_index++;
			if(prev_index!=-INF && A[i]==0) prev_index = -INF;
		}
		if(A[i]%2==1){
			ans += A[i]/2;
			if(prev_index==-INF){
				prev_index = i;
			}
			else{
				if(prev_index==i-1){
					ans++;
					prev_index = -INF;
				}
			}
		}
	}
}
 
int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];
 
    solve();

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;

  vector<int> ruiseki(N);
  for (int i = 0; i < N; ++i) {
    if (i == 0) {
      ruiseki[i] = 0;
      continue;
    }
    if (S[i - 1] == 'A' and S[i] == 'C') {
      ruiseki[i] = ruiseki[i - 1] + 1;
    } else {
      ruiseki[i] = ruiseki[i - 1];
    }
  }

  int l, r;
  for (int i = 0; i < Q; ++i) {
    cin >> l >> r;
    if (r == 1) {
      cout << ruiseki[r - 1] << endl;
    } else {
      cout << ruiseki[r - 1] - ruiseki[l - 1] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	rep(i, N) {
		cin >> a[i];
	}

	vector<int> cnt(9, 0);

	rep(i, N) {
		int tmp = a[i] / 400;
		if (tmp <= 7) {
			cnt[tmp]++;
		}
		else {
			cnt[8]++;
		}
	}
	int mn = 0;
	rep(i, 8) {
		if (cnt[i] > 0) {
			mn++;
		}
	}
	int mx = mn + cnt[8];
	if (mn == 0) {
		mn = 1;
	}
	cout << mn << " " << mx;
	return 0;
}

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

int main(void){

  int num1,num2;
  char op;
  int ans;

  while(cin >> num1 >> op >> num2){
    if(op == '+') ans = num1 + num2;
    else if(op == '-') ans = num1 - num2;
    else if(op == '*') ans = num1 * num2;
    else if(op == '/') ans = num1 / num2;
    else break;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int num;
    num = 100*a+10*b+c;
    if(num%4==0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}




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

using namespace std;

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> a(m);
    for(auto&& i : a){
        cin >> i.first >> i.second;
    }
    sort(begin(a), end(a), comp);
    int ans = 0, p = 0;
    for(auto&& i : a){
        if(p < i.first){
            p = i.second - 1;
            ans++;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1024
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */

    //#pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(int i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(int i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(int i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    #define mp make_pair
    #define pb push_back
    //#define M_PI           3.1415926535  /* pi */
    typedef long double ld;
    typedef long long ll;
    typedef pair<int, int> pii;
    typedef vector<ll> vi;
    const int maxN = 100224;

    void solve(){
      ll n, m,x,y;
      cin >> n >> m >> x >> y;
      ll ans = (n-x)*(m-y);
      cout<<ans<<endl;
    }
    
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      solve();
      return 0;
    }   

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <iostream>
#include <math.h>
using namespace std;





int main() {
	char a[4] = { 0 };
	
	char b[4] = "abc";
	scanf("%s", a);
	sort(a, a + 3);
	int p = strcmp(a, "abc");
	if (!strcmp(a, "abc"))printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

bool dbgflag = false;

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

  ll n, c;
  cin >> n >> c;
  vector<ll> vl(n), vr(n);
  vector<pll> values(n);
  for (int i = 0; i < n; i++) cin >> values[i].second >> values[i].first;
  ll get = 0, value_sum = 0;
  for (int i = 0; i < n; i++) {
    //vl[i+1].second = values[i].second;
    //vl[i+1].first += values[i].first; 
    value_sum += values[i].first;
    get = max(get, value_sum - values[i].second);
    vr[i] = get;
  }
  value_sum = 0, get = 0;
  for (int i = 0; i < n; i++) {
    //vl[i+1].second = c - values[n-i].second;
    //vl[i+1].first += values[n-i].first;
    value_sum += values[n-1-i].first;
    get = max(get, value_sum - (c - values[n-1-i].second));
    vl[i] = get;
  }
  //左→右
  ll best_lr = vr[n-1];//max((ull)0, vr[n-1]);
  for (int b = 0; b < n-1; b++) {
    //cout << values[n-1-b].first - 2 * (c - values[n-1-b].second) + vr[n-2-b] << endl;
    best_lr = max(best_lr, vl[b] - (c - values[n-1-b].second) + vr[n-2-b]);
  }
  ll best_rl = vl[n-1];//max((ull)0, vl[n-1]);
  for (int b = 0; b < n-1; b++) {
    //cout << values[b].first - 2 * values[b].second + vl[n-2-b] << endl;
    best_rl = max(best_rl, vr[b] - values[b].second + vl[n-2-b]);
  }

  //for (int i = 0; i < n; i++) cout << vl[i] << endl;
  //for (int i = 0; i < n; i++) cout << vr[i] << endl;

  cout << max(best_rl, best_lr) << endl;
}


Measured memory_bytes: 3456
import sys, collections
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    n = I()
    Adj = [[0]*n for _ in range(n)]
    for _ in range(n):
        ukv = LI()
        u = ukv[0]
        # k = ukv[1]
        v = ukv[2:]
        for i in v:
            Adj[u-1][i-1] = 1

    for i in Adj:
        print(*i)

if __name__ == '__main__':
    resolve()



Measured memory_bytes: 6764
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,m,i,j,cnt,q,a[100002],b[100002];
    while(cin>>n)
    {
        cnt=0;
        for(i=0;i<n;i++) cin>>a[i]>>b[i];
        for(i=n-1;i>=0;i--)
        {
            a[i]+=cnt;
            if(a[i]%b[i]!=0)
            {
                m = (a[i])/b[i];
                //p = a[i]%b[i];
                q = (m+1)*b[i];
                cnt+=q-(a[i]);
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 1792
s = gets.chomp
len = s.length
len -= 1

(0..len).each do |i|
  (i..len).each do |j|
    str = s[0...i] + s[j..-1]
    
    if str == "keyence"
      puts "YES"
      exit
    end
  end
end

puts "NO"


Measured memory_bytes: 14248
class Somesomes:
  def sum(self, num_list):
    result_dict={}
    for n in num_list:
      add_num = 0
      num_str = list(str(n))
      for l in num_str:
        add_num +=int(l)
      result_dict[n]=add_num
    return result_dict

  def extract_num(self, num_dict, start, end):
    extract_list=[]
    for n in num_dict.keys():
      if start <= num_dict[n] <= end:
        extract_list.append(n)
    return extract_list

  def sum_result(self, result_extract):
    result_sum = 0
    for r in result_extract:
      result_sum +=r
    return result_sum

if __name__ == '__main__' :
  I=list(map(int, input().split()))
  N = I[0]
  A = I[1]
  B = I[2]
  num_list=[]
  for n in range(N):
    num_list.append(n+1)
  somesomes = Somesomes()
  result_dict=somesomes.sum(num_list)
  result_extract = somesomes.extract_num(result_dict, A, B)
  result_sum = somesomes.sum_result(result_extract)
  print(result_sum)


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

using namespace std;

string S, T;

bool check() {
    if (S.size() != T.size()) return false;
    for (int i = 0; i < S.size(); i++) {
        bool good = true;
        for (int j = 0; j < T.size(); j++) {
            if (S[j] != T[(j + i) % T.size()]) {
                good = false;
                break;
            }
        }
        if (good) return true;
    }
    return false;
}

int main() {
    cin >> S >> T;
    cout << (check() ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> P;

const ll p = 1000000007;

const ll fact_max = 200002;

ll fact[fact_max];
ll fact_inv[fact_max];
ll inv[fact_max];

void fact_init(){
  fact[0] = fact[1] = 1;
  fact_inv[0] = fact_inv[1] = 1;
  inv[1] = 1;
  for(ll i = 2; i < fact_max; i++){
    fact[i] = fact[i-1] * i % p;
    inv[i] = p - inv[p%i] * (p/i) % p;
    fact_inv[i] = fact_inv[i-1] * inv[i] % p;
  }
}

ll calc_comb(ll x, ll y){
  if(x<0||y<0) return 0;
  return fact[x+y] * (fact_inv[x] * fact_inv[y] % p) % p;
}

int main(){
  fact_init();
  ll h,w,n;
  cin >> h >> w >> n;
  vector<P> dst;
  REP(i,n){
    ll r,c; cin >> r >> c;
    r--, c--;
    dst.push_back(P(r,c));
  }
  sort(dst.begin(),dst.end());
  dst.push_back(P(h-1,w-1));
  n++;
  ll dp[n];
  REP(i,n){
    dp[i] = calc_comb(dst[i].first,dst[i].second);
    REP(j,i){
      dp[i] -= dp[j] * calc_comb(dst[i].first-dst[j].first,dst[i].second-dst[j].second) % p;
      if(dp[i]<0) dp[i] += p;
    }
    //cout << dp[i] << endl;
  }
  cout << dp[n-1] << endl;
  return 0;
}


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

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		long[][] dp = new long[n + 1][n + 1];

		for (int d = 1; d <= n; d++) {
			for (int l = 0; l <= n; l++) {
				int r = l + d;
				if (r > n) break;
				if ((n - d) % 2 == 0) {
					// maximize
					dp[l][r] = Math.max(dp[l + 1][r] + a[l], dp[l][r - 1] + a[r - 1]);
				} else {
					// minimize
					dp[l][r] = Math.min(dp[l + 1][r] - a[l], dp[l][r - 1] - a[r - 1]);
				}
			}
		}

		System.out.println(dp[0][n]);
	}
}


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

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

    int size = s.size();
    for (int i = size-2; i >= 0; i-=2) {
        if (s.substr(0, i/2) == s.substr(i/2, i/2)) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    int d[k];
    vector<bool>snuke(n+1,false);
    for(int i=0;i<k;i++){
        cin >> d[i];
        for(int j=0;j<d[i];j++){
            int a;
            cin >> a;
            snuke[a] = true;
        }
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        if(!snuke[i])ans++;
    }
    cout << ans << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define POW(n) ((n)*(n))
#define ALL(a) (a).begin(),(a).end()
#define cerr if(false) cerr
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

void solve(long long N, long long K){
	ll ans = 1;
  
  REP(i,N){
    if(i == 0){
      ans *= K;
    }else{
      ans *= K-1;
    }
  }
  
  cout << ans << endl;
}



int main(){	
	ios::sync_with_stdio(false);
	long long N;
	long long K;
	cin >> N;
	cin >> K;
	solve(N, K);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

int main(){ 
  int a, b, c;
  cin >> a >> b;
  
  cout << 6 - a - b << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int group1[] = { 1,3,5,7,8,10,12 };
int group2[] = { 4,6,9,11 };

int solve(int x)
{
	for (int i = 0; i < 7; i++)
	{
		if (group1[i] == x)
			return 0;
	}

	for (int i = 0; i < 4; i++)
	{
		if (group2[i] == x)
			return 1;
	}

	return 2;
}


int main()
{
	int x, y;

	cin >> x >> y;

	if (solve(x) == solve(y))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	// Code for A - Grouping
	var x, y int
	fmt.Scanf("%d %d", &x, &y)

	a := []int{0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1}

	if a[x] == a[y] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1832
from collections import Counter
N = int(input())#blue card +
s = list(input() for i in range(N))
M = int(input())#red card -
t = list(input() for i in range(M))
count_p = Counter(s)
count_m = Counter(t)
counter = count_p - count_m
if (len(counter.values()) == 0):
    print (0)
else:
    print(max(counter.values()))

Measured memory_bytes: 9348
def show (nums):
    for i in range(len(nums)):
        if i!=len(nums)-1:
            print(nums[i],end=' ')
        else :
            print(nums[i])
 
n=int(input())
nums=list(map(int,input().split()))
show(nums)
for i in range(1,n):
    v=nums[i]
    j=i-1
    while (j>=0 and nums[j]>v):
        nums[j+1]=nums[j]
        j-=1
    nums[j+1]=v
    show(nums)
 
    


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

int main()
{
    int N, K, Q; cin >> N >> K >> Q;
    vector<int> a(Q),b(N+1,0);
    for(int i=0;i<Q;i++) cin >> a[i];
    for(int i=0;i<Q;i++){
        b[a[i]-1]++;
    }
    for(int i=0;i<N;i++){
        if(K-Q+b[i] <= 0){
            cout << "No" << endl;
        }
        else cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  int counter = 0;
  bool canDevide = true;
  while (canDevide) {
    for (int i = 0; i < (int)A.size(); i++) {
      if (A.at(i) % 2 == 1) {
        canDevide = false;
        break;
      }
      A[i] = A[i] / 2;
    }
    if (canDevide) counter++;
  }

  cout << counter << endl;
  return 0;
}

// 標準入出力
//int main() {
//	int a, b;
//	cin >> a >> b;
//  if (a * b % 2 == 0) {
//	  cout << "Even" << endl;
//  } else {
//	  cout << "Odd" << endl;
//  }
//  return 0;
//}

// 文字列を1文字ずつループ
//int main() {
//  string str;
//  cin >> str;
//  int sum = 0;
//  for(int i = 0; i < (int)str.size(); ++i){
//    char ch = str[i];
//
//    if (ch == '1') {
//      sum++;
//    }
//  }
//  cout << sum << endl;
//  return 0;
//}


Measured memory_bytes: 256
judge [] = True
judge (x:xs) = (x == 'R' || x == 'U' || x == 'D') && judge' xs

judge' [] = True
judge' (x:xs) = (x == 'L' || x == 'U' || x == 'D') && judge xs

main = do
	s <- getLine
	putStrLn $ if judge s then "Yes" else "No"


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

int main(){
  int n; cin >> n;
  string s; cin >> s;
  int dp[5001][5001] = {};
  for(int i = n - 1; i >= 0; --i){
    for(int j = n - 1; j >= 0; --j){
      if(s[i] == s[j]) dp[i][j] = dp[i+1][j+1] + 1;
    }
  }
  int ans = 0;
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < n; ++j){
      if(i < j) ans = max(ans, min(j-i, dp[i][j]));
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 98048
n, k, c = map(int, input().split())
s = input()

def solve_dp(s):
  dp = [0]*(n+2)
  for i in range(n):
    if i <= c and s[i] == 'o':
      dp[i+1] = 1
    else:
      if s[i] == 'o':
        dp[i+1] = max(dp[i], dp[i-c]+1)
      else:
        dp[i+1] = dp[i]
  return dp

mae = solve_dp(s)
ushiro = solve_dp(s[::-1])[::-1]

for i in range(1,n+1):
  if mae[i-1] + ushiro[i+1] < k:
    print(i)

Measured memory_bytes: 20772
while 1:
 a=b=0;n=int(input())
 if n==0:break
 for i in[0]*n:
  s,t=map(int,input().split())
  if s<t:b+=s
  else:a+=s
  if s>t:a+=t
  else:b+=t
 print(a,b)


Measured memory_bytes: 5724
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    string S,T;
    cin >> S >> T;

    cout << T + S << endl;
}

Measured memory_bytes: 256
def function(a, b)
	s_a = (0...a).map { |_| b.to_s }.join
	s_b = (0...b).map { |_| a.to_s }.join
	s_a <= s_b ? s_a : s_b
end

a, b = gets.chomp.split.map(&:to_i)
puts function(a, b)


Measured memory_bytes: 3836
def main():
    s = input()
    a = s[:2]
    b = s[2:]

    az = int(a) == 0
    ap = 0 < int(a) < 100
    am = 0 < int(a) < 13
    bz = int(b) == 0

    bp = 0 < int(b) < 100
    bm = 0 < int(b) < 13
    if ap and am and bp and bm:
        print('AMBIGUOUS')
    elif ap and am and (bz or bp) and not bm:
        print('MMYY')
    elif (az or ap) and not am and bp and bm:
        print('YYMM')
    else:
        print('NA')


main()



Measured memory_bytes: 3064
#include<cstdio>  
#include<iostream>  
#include<algorithm>  
#include<cstdlib>  
#include<cstring>
#include<string>
#include<climits>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<ctime>
#define LL long long
#define inf 0x3f3f3f3f

using namespace std;
  
inline char nc(){
    /* 
  static char buf[100000],*p1=buf,*p2=buf;
  if (p1==p2) { p2=(p1=buf)+fread(buf,1,100000,stdin); if (p1==p2) return EOF; }
  return *p1++;
    */return getchar();
}
  
inline void read(int &x){
  char c=nc();int b=1;
  for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
  for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}
  
inline void read(LL &x){
  char c=nc();LL b=1;
  for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
  for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}
 
inline int read(char *s)
{
    char c=nc();int len=1;
    for(;!(c=='.'||c=='#');c=nc()) if (c==EOF) return 0;
    for(;(c=='.'||c=='#');s[len++]=c,c=nc());
    s[len++]='\0';
    return len-2;
}
 
inline void read(char &x){
  for (x=nc();!(x>='0' && x<='1');x=nc());
}
 
int wt,ss[19];
inline void print(int x){
    if (x<0) x=-x,putchar('-'); 
    if (!x) putchar(48); else {
    for (wt=0;x;ss[++wt]=x%10,x/=10);
    for (;wt;putchar(ss[wt]+48),wt--);}
}
inline void print(LL x){
    if (x<0) x=-x,putchar('-');
    if (!x) putchar(48); else {for (wt=0;x;ss[++wt]=x%10,x/=10);for (;wt;putchar(ss[wt]+48),wt--);}
}

int n,q[100010];
LL m,T,a[100010],f[100010],Minout;


int main()
{
    read(n);read(m);read(T);
    for (int i=1;i<=n;i++)
        read(a[i]),f[i]=m*10+T*10;
    int l=1,r=1;
    LL z=m*10+T*10;
    for(int i=1;i<=n;i++)
    {
        while(l<=r&&2*(a[i]-a[q[l]+1])>T)
            z=min(z,f[q[l]]-a[q[l]]-2*a[q[l]+1]),l++;
        f[i]=min(f[i],a[i]+z+2*a[i]);
        f[i]=min(f[i],f[q[l]]+a[i]-a[q[l]]+T);
        while(l<=r&&f[q[l]]-a[q[l]]>=f[i]-a[i]) r--;
        q[++r]=i;
    }
    LL ans=f[n]+m-a[n];
    print(ans),puts("");
   return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
  IOS();
  int d[3];
  REP(i,3) cin>>d[i];
  sort(d,d+3,greater<int>());
  cout<<d[0]*10+d[1]+d[2]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c; cin>>a>>b>>c;
  int k; cin>>k;
  int n=0;
  while(a>=b){
    b*=2;
    n++;
  }
  while(b>=c){
    c*=2;
    n++;
  }
  cout<<((n>k)?"No":"Yes")<<endl;
}



Measured memory_bytes: 3596
from collections import defaultdict

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = [a % M for a in A]

accA = [0] * (N + 1)
for i, a in enumerate(A, start=1):
    accA[i] = accA[i - 1] + a

cnt = defaultdict(int)
for a in accA:
    cnt[a % M] += 1

def ncr(n, r):
    if n < 0 or r < 0 or n < r:
        return 0
    ret = 1
    for i in range(n, n - r, -1):
        ret *= i
    for i in range(1, r + 1):
        ret //= i
    return ret

ans = 0
for c in cnt.values():
    ans += ncr(c, 2)

print(ans)

Measured memory_bytes: 17564
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    vector<vector<int>> a(n,vector<int>(n-1,0));
    rep(i,n)rep(j,n-1) {cin>>a[i][j];a[i][j]--;}
    vector<int> now(n,0);
    int ans=-1;
    int cnt=1;
    while(cnt){
        cnt=0;
        vector<bool> bat(n,false);
        rep(i,n){
            if(now[i]==n-1) continue;
            int op=a[i][now[i]];
            if(bat[op] || bat[i]) continue;
            if(a[ op ][ now[op] ] != i) continue;
            cnt ++;
            now[i] ++;
            now[op] ++;
            bat[i] =true;
            bat[op]=true;
        }
        ans ++;
    }
    rep(i,n){
        if(now[i]<n-1){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 7548
#include <iostream>
#include <vector>
#include <algorithm>
#define INF 1<<29

using namespace std;

int Cost(vector<int> const &d, int k) {
	int i = 0, ans = 0;
	for (; i < d.size(); i++)
		ans += (d[i] - k) * (d[i] - k);
	return ans;
}

int main(void) {
	int num, i = 0, mi = 100, ma = -100, ans = INF;
	cin >> num;
	vector<int> d(num);
	for (; i < num; i++) {
		scanf("%d", &d[i]);
		mi = min(mi, d[i]);
		ma = max(ma, d[i]);
	}
	for (i = mi; i <= ma; i++)
		ans = min(ans, Cost(d, i));
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

#define int long

#define REP(i,f,n) for(int i=(f); i < (n); ++i)
#define PER(i,f,n) for(int i=(n-1); i >= f; --i)

constexpr int evx[4] = { 1, 0, -1, 0 };
constexpr int evy[4] = { 0, 1, 0, -1 };

//----------------------------------
//----------------------------------

signed main()
{
    ios::sync_with_stdio(false);
        string s;
        cin >> s;
        cout <<( (s.size() % 2) + (s[0] == s[s.size()-1]) == 1 ? "First\n" : "Second\n");

}


Measured memory_bytes: 640
n,w=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
dp=[[0]*(w+1) for i in range(n+1)]
for i in range(1,n+1):
  for j in range(w+1):
    if j-l[i-1][0]>=0:
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-l[i-1][0]]+l[i-1][1])
    else:
      dp[i][j]=dp[i-1][j]
print(max(dp[n]))

Measured memory_bytes: 120172
#include <stdio.h>
#include <string.h>

void heisei(){
	printf("Heisei\n");
}

int main(void){
	int y,m,d;
	scanf("%d/%d/%d",&y,&m,&d);
	if(y > 2019){
		printf("TBD\n");
	}else if(y == 2019){
		if(m > 4){
			printf("TBD\n");
		}else if(m == 4){
			if(d > 30){
				printf("TBD\n");
			}else{
				printf("Heisei\n");
			}
		}else{
			printf("Heisei\n");
		}
	}else{
		printf("Heisei\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	int N, q;
	cin >> N >> q;

	queue<pair<string, int> > Queue;

	for (int i = 0;i < N;i++)
	{
		string name;
		int time;
		cin >> name >> time;
		Queue.push(make_pair(name, time));
	}

	int sum = 0;
	while (!Queue.empty())
	{
		pair<string, int> pro = Queue.front(); Queue.pop();
		sum += min(pro.second, q);

		pro.second -= q;

		if (pro.second > 0)
			Queue.push(pro);
		else
			cout << pro.first << " " << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 6304
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
#define endl '\n'
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; }
using namespace std;

signed main(void){
    int h,w,n; cin>>h>>w>>n;
    vector<P> vec(n);
    rep(i,n)cin>>vec.at(i).F>>vec.at(i).S;
    sort(all(vec));
    vector<int> ans(10,0);
    ans.front()=(h-2)*(w-2);
    rep(i,n){
        P p=vec.at(i);
        rep(j,3)rep(k,3){
            int x=p.F-j,y=p.S-k;
            if(x<=0 or y<=0 or x+2>h or y+2>w)continue;
            int cnt=0;
            rep(l,3)rep(m,3)if(binary_search(all(vec),P(x+l,y+m)))cnt++;
            ans.at(cnt)++;
        }
    }
    int sum=0;
    for(int i=1; i<=9; i++){
        ans.at(i)/=i;
        sum+=ans.at(i);
    }
    cout<<ans.front()-sum<<endl;
    rep(i,9)cout<<ans.at(i+1)<<endl;
}

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

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

int n;

void dfs(string s, char mx) {
  if(s.size() == n) {
    cout << s << endl;
    return;
  }
  for(char c = 'a'; c <= mx+1; c++) {
    string t = s;
    t += c;
    dfs(t, max(mx, c));
  }
}

int main() {
  cin >> n;
  dfs("", 'a'-1);
  return 0;
}

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

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


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

int h,w;
int a[SIZE][SIZE];
int a2[SIZE][SIZE];

void rotate(){
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      a2[j][h-1-i] = a[i][j];
    }
  }

  swap(w,h);
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      a[i][j] = a2[i][j];
      //printf("%d ",a[i][j]);
    }
    //puts("");
  }
  
}

int dp[2][SIZE][SIZE] = {};

int main(){
  int min_a = INF, max_a = 0;
  
  scanf("%d%d",&h,&w);

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      scanf("%d",a[i]+j);
      min_a = min(a[i][j], min_a);
      max_a = max(a[i][j], max_a);
    }
  }

  if(min_a == max_a){
    puts("0");
    return 0;
  }
  
  int ans = INF;
  
  for(int q=0;q<2;q++){

    for(int i=0;i<=h;i++){
      for(int j=0;j<=w;j++){
        dp[0][i][j] = dp[1][i][j] = INF;
      }
    }

    dp[0][0][0] = dp[1][0][0] = 0;
    
    //?¨?
    for(int i=0;i<h;i++){

      priority_queue<pair<int,int> > pq_max;
      priority_queue<pair<int,int> > pq_min;

      for(int j=0;j<w;j++){
        pq_max.push({a[i][j],j});
        pq_min.push({-a[i][j],j});
      } 
      
      int min_a2 = INF, max_a2 = 0;
      int dp_memo1 = INF, dp_memo2 = INF; 
      
      for(int j=0;j<=w;j++){
        while(pq_max.size() && pq_max.top().second < j) pq_max.pop();
        while(pq_min.size() && pq_min.top().second < j) pq_min.pop();

        dp_memo1 = min(dp_memo1, dp[0][i][j]);
        dp_memo2 = min(dp_memo2, dp[1][i][j]);

        int pq_max_f, pq_min_f;

        if(pq_max.size()){
          pq_max_f = pq_max.top().first;
        }else{
          pq_max_f = 0;
        }
        if(pq_min.size()){
          pq_min_f = -pq_min.top().first;
        }else{
          pq_min_f = INF;
        }
        
        // max\min
        if(min_a2 != min_a && pq_max_f != max_a){
          dp[0][i+1][j] = min(dp[0][i+1][j],
                              max({dp_memo1, max_a-min_a2, pq_max_f - min_a}));
        }

        // min\max
        if(max_a2 != max_a && pq_min_f != min_a){
          dp[1][i+1][j] = min(dp[1][i+1][j],
                              max({dp_memo2, max_a2-min_a, max_a - pq_min_f}));
        }
        
        min_a2 = min(min_a2,a[i][j]);
        max_a2 = max(max_a2,a[i][j]);
      }

    }

    int this_ans = INF;
    
    for(int i=0;i<=w;i++){
      ans = min({ans, dp[0][h][i],dp[1][h][i]});
      this_ans = min({this_ans, dp[0][h][i],dp[1][h][i]});
    }
    
    //debug(this_ans);
    
    rotate();
  }

  if(ans == INF){
    ans = max_a - min_a;
  }
  
  printf("%d\n",ans);
  
  return 0;
}


Measured memory_bytes: 66088
#include<stdio.h>
int main(void){
    int w,a,b,temp;
    scanf("%d %d %d",&w,&a,&b);
    if(a>b){
        temp=a;
        a=b;
        b=temp;
    }else if(a==b){
        printf("0\n");
        return 0;
    }
    if(a+w>b){
        printf("0\n");
    }else{
        printf("%d\n",b-(a+w));
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    string S;
    cin >> S;
    ll len = S.size();
    vector<ll> straight(len + 1);
    vector<ll> reverse(len + 1);
    straight[0] = 0;
    reverse[len] = 0;
    ll straight_count = 0;
    ll reverse_count = 0;
    ll ans = 0;
    rep(i,len){
        if (S[i] == '<'){
            straight_count++;
        }
        else{
            straight_count = 0;
        }
        straight[i + 1] = straight_count;
    }
    for (ll i = len - 1; i >= 0; i--){
        if (S[i] == '>'){
            reverse_count++;
        }
        else{
            reverse_count = 0;
        }
        reverse[i] = reverse_count;
    }
    rep(i,len + 1){
        ans += max(straight[i], reverse[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 8708
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){
    int K;
    cin >> K;
    cout << (K/2) * ((K-1)/2+1);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int num = sc.nextInt();
    static int k = sc.nextInt();
    static int[] h = new int[num];
    static int[] dp = new int[num];
    public static void main(String[] args) {
        for (int i = 0; i < num; i++){
            h[i] = sc.nextInt();
            dp[i] = 2147483647;
        }
        dp[0] = 0;
        dp[1] = Math.abs(h[1] - h[0]);
        for (int i = 2; i < num; i++){
            for (int j = 1; j <= k && i - j >= 0; j++){
                chmin(dp[i],dp[i - j] + Math.abs(h[i] - h[i - j]), i);
//                if (dp[i] > dp[i - j] + Math.abs(h[i] - h[i - j]))
//                    dp[i] = dp[i - j] + Math.abs(h[i] - h[i - j]);
            }
        }
        System.out.println(dp[num - 1]);
    }
    public static void chmin(int a, int b, int i){
        if (a > b)
            dp[i] = b;
    }
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){

  string s;
  cin >> s;
  cout << "ABC" + s << endl;





  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  map<int,int> m;
  REP(j,1,n+1) {
    ll x=j;
    for(int i=2; i*i<=x; i++) {
      if(x%i==0) {
        ll cnt=0;
        while(x%i==0) {
          cnt++;
          x/=i;
        }
        m[i]+=cnt;
      }
    }
    if(x!=1) m[x]++;
  }
  ll ans=1;
  tr(it,m) {
    ans*=it->S+1;
    ans%=MAX;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int a,b;
  cin >> a >> b;
  cout << (a+b)/2+(a+b)%2 << endl;
}


Measured memory_bytes: 256