akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

template<long long mod>
class modint{
private:
  long long a;
public:
  constexpr modint(const long long x = 0) noexcept : a(x%mod) {}
  constexpr long long& value() noexcept { return a; }
  constexpr const long long& value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    long long k = mod-2;
    while(k > 0){
      if(k&1){
        *this *= rhs;
      }
      rhs *= rhs;
      k /= 2;
    }
    return *this;
  }
  friend ostream& operator<<(ostream &os, const modint &X){
    return os << X.a;
  }
  friend istream& operator>>(istream &is, modint &X){
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};

int main(){
  using mint = modint<(int)1e9+7>;
  int N, K;
  cin >> N >> K;
  mint ans = 0;
  for(long long i = K; i <= N+1; ++i){
    long long mi = i*(i-1)/2;
    long long ma = (2*N-i+1)*i/2;
    ans += (ma-mi+1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3616
/* ABC137-A
   Takatan */

#include<stdio.h>
int main(void){
    int a, b, sum, dif, mul;

    scanf( "%d %d" , &a, &b);
    sum = a + b; /* 和を算出 */
    dif = a-b; /* 差を算出 */
    mul = a * b; /* 積を算出 */

    if(sum<dif){
        sum = dif; /* 大きいものをsumに保存 */
    }
    if(sum<mul){
        sum = mul; /* 大きいものをsumに保存 */
    }
    printf( "%d\n" , sum); /* 出力 */
    return 0;
}

Measured memory_bytes: 128
n, t = map(int, input().split())
a = [int(i) for i in input().split()]

count = 0
m = a[0]
maxrieki = 0

for i in range(n):
    if( m > a[i]):
        m = a[i]
    else:
        if(maxrieki < (a[i] - m)):
            maxrieki = a[i] - m
            count = 1
        elif(maxrieki != 0 and maxrieki == (a[i]-m)):
            count+=1

print(count)


Measured memory_bytes: 14252
import sys
n=int(input())
x=list(map(int,input().split()))
y=sorted(x)
mid1=y[(n//2)-1]
mid2=y[n//2]
if mid1==mid2:
  for j in range(n):
    print(mid1)
  sys.exit()
for i in range(n):
  if x[i]<mid1:
    print(mid2)
  if x[i]==mid1 and x.count(mid1)>2:
    print(mid1)
  if x[i]==mid1 and x.count(mid1)<3:
    print(mid2)
  if x[i]==mid2 and x.count(mid2)>2:
    print(mid2)
  if x[i]==mid2 and x.count(mid2)<3:
    print(mid1)
  if x[i]>mid2:
    print(mid1)
  
  


Measured memory_bytes: 26772
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
using namespace std;
int main(){
    int N,M;
    cin >> N >> M;
    int ans = 0;
    int MMM = 1;
    for(int i=0;i<M;i++){
        MMM *= 2;
    }
    for(int i=0;i<MMM;i++){
        ans += (N-M)*100 + M*1900;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
SIZE=1000000; MOD=10**9+7 #998244353 #ここを変更する

SIZE += 1
inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
fac = [0]*SIZE  # fac[j] = j! mod MOD
finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD
inv[1] = 1
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE):
    inv[i] = MOD - (MOD//i)*inv[MOD%i]%MOD
    fac[i] = fac[i-1]*i%MOD
    finv[i]= finv[i-1]*inv[i]%MOD

def choose(n,r): # nCk mod MOD の計算
    if 0 <= r <= n:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    else:
        return 0

def chofuku(ball,box): # nHk mod MOD の計算
    return choose(box+ball-1,box)


import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

#n = int(input())
#a = [int(i) for i in readline().split()]
x,y = [int(i) for i in readline().split()]


xx = x-2*y
yy = (-2)*x+y

ng = 0

if xx%3 != 0: ng = 1
if yy%3 != 0: ng = 1

xx //= 3 
yy //= 3
xx *= -1
yy *= -1

#print(ng,xx,yy)

if ng: print(0)
else: print(choose(xx+yy,xx)%MOD)









Measured memory_bytes: 64748
import java.util.Scanner;

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

    int n = stdIn.nextInt();
    int k = stdIn.nextInt();
    int q = stdIn.nextInt();
    int[] a = new int[q];
    for (int i = 0; i < q; i++) {
      a[i] = stdIn.nextInt();
    }

    int[] point = new int[n];
    for (int i = 0; i < n; i++) {
      point[i] = k;
    }

    int[] count = new int[n];
    for (int i = 0; i < q; i++) {
      count[a[i]-1]++;
    }

    for (int i = 0; i < n; i++) {
      point[i] = point[i] - q + count[i];
      if (point[i] > 0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    }
  }
}


Measured memory_bytes: 68092
#include <bits/stdc++.h>
 
#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(int i=n;i<=N;++i)
#define rap(i,n,N) for(int i=n;i>=N;--i)
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cout << ">>>>>> " << #x << " -> " << x << endl
#define all(x) x.begin(),x.end()
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define pllll pair<pll,pll>
#define piii pair<int,pii>
#define piiii pair<pii,pii>
#define psi pair<string,int>
#define endl '\n'
const int MAX = 6e5+5;
const ll MAX2 = 11;
const ll MOD = 1000000007;
const ll MOD2 = 1000000006;
const ll INF = 2e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 316;
 
ll x,y;

int main(){
//	cout<<fixed<<setprecision(10);
//    freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>x>>y;
    cout<<max(0ll,x-y)<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt();
			if(n == 0) break;
			Ctt[] ctts = new Ctt[n];
			for(int i=0;i<n;i++) {
				ctts[i] = new Ctt(sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt());
			}
			sort(ctts, new Comp());
			int uni[] = new int[1000];
			int cnt=0;
			for(int i=0;i<n;i++) {
				if(cnt<10 && uni[ctts[i].u-1] < 3) {
					cnt++;
					System.out.println(ctts[i].i);
					uni[ctts[i].u-1]++;
				}
				else if(cnt<20 && uni[ctts[i].u-1] < 2) {
					cnt++;
					System.out.println(ctts[i].i);
					uni[ctts[i].u-1]++;
				}
				else if(cnt<26 && uni[ctts[i].u-1]<1) {
					cnt++;
					System.out.println(ctts[i].i);
					uni[ctts[i].u-1]++;
				}
				if(cnt==26) break;
			}
			
		}
	}
	
	class Comp implements Comparator<Ctt> {

		@Override
		public int compare(Ctt o1, Ctt o2) {
			// TODO 自動生成されたメソッド・スタブ
			if(o1.a < o2.a) return 1;
			else if( o1.a > o2.a) return -1;
			else {
				if(o1.p > o2.p) return 1;
				else if(o1.p < o2.p) return -1;
				else {
					return o1.i - o2.i;
				}
			}
		}
		
	}
	
	class Ctt {
		int i, u, a, p;
		Ctt (int i, int u, int a, int p){
			this.i = i;
			this.u = u;
			this.a = a;
			this.p = p;
		}
	}

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

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

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

typedef long long ll;
typedef long double ld;
//#define int ll
//#define endl '\n'

// use unique(x) - removec consecutive items, returns vec.begin() + number of items
// for vector: sort(all(vec)); vec.erase(unique(all(vec)), vec.end());
// use iota(all(vec), 0) for filling a vector with 0,1,2...
// use fill(all(vec), 1) for filling a vector with 1,1,1...
// use rotate(vec.begin(), vec.begin() + 1, vec.end()) to rotate a vector | middle arg becomes first
// print number in binary -> cout << bitset<20>(n);

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }
// returns a vector of primes upto n,
// also creates a vector (a) of size n, that contains
// the highest prime factor of each number upto n
// time: O(n log log n)
vector<ll> e; // a[i]=highest prime factor of i
vector<ll> erat (ll n){
    e = vector<ll>(n,0);
    vector<ll> primes;
    e[0] = e[1] = 1;
    for (ll i = 2; i < n; ++i){
        if (!e[i]){
            primes.push_back(i);
            for (ll j = i; j < n; j += i) e[j] = i;
        }
    }
    return primes;
}
const int N=1000100,mod=1e9+7;
int a[N];
int n;
main(){
	cin.tie(0);cin.sync_with_stdio(0);
	erat(N);
	cin>>n;
	for(int i=0;i<n;++i)cin>>a[i];
	int gc=a[0];
	for(int i=0;i<n&&gc!=1;++i)gc=gcd(gc,a[i]);
	if(gc!=1){cout<<"not coprime\n";return 0;}
	bool pos=true;
	set<int>totalprimes;
	for(int i=0;i<n&&pos;++i){
		set<int>primes;
		while(a[i]!=1){
			primes.insert(e[a[i]]);
			a[i]/=e[a[i]];
		}
		for(auto it=primes.begin();it!=primes.end();++it)
			if(totalprimes.count(*it))pos=false;
			else totalprimes.insert(*it);
	}
	if(pos)cout<<"pairwise coprime\n";
	else cout<<"setwise coprime\n";
}


Measured memory_bytes: 14992
s = input()
k = int(input())

ans = 0
rep = 1
first_rep = 1

tmp = None
for i in s:
    if tmp:
        if tmp == i:
            first_rep += 1
        else:
            break
    else:
        tmp = i

if first_rep == len(s):
    print(len(s) * k // 2)
    exit(0)


for i in range(0, len(s) - 1):
    current = s[i]
    next = s[i+1]
    if current == next:
        rep += 1
    else:
        if rep > 1:
            ans += rep // 2
            rep = 1

if rep > 1:
    ans += rep // 2

start_eq_end = 0
if len(s) > 2 and s[0] == s[-1] and first_rep % 2 != 0:
    if rep % 2 != 0:
        start_eq_end = k - 1


print(ans * k + start_eq_end)

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

#define ED return 0;
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) int(pow(x,y))
const long long mod = 1000000007;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> vec (H);
    vector<bool> Wtest (H,false);
    vector<bool> Htest (W,false);
    for(int i = 0;i < H;i++){
        cin >> vec.at(i);
        bool test = true;
        for(int j = 0;j < W;j++){
            if(vec.at(i).at(j) == '#'){
                test = false;
            }
        }
        if(test){
            Wtest.at(i) = true;
        }
    }
    for(int i = 0;i < W;i++){
        bool test = true;
        for(int j = 0;j < H;j++){
            if(vec.at(j).at(i) == '#'){
                test = false;
            }
        }
        if(test){
            Htest.at(i) = true;
        }
    }

    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            if(Htest.at(j) == false && Wtest.at(i) == false){
                cout << vec.at(i).at(j);
            }
        }
        if(Wtest.at(i) == false){
        cout << endl;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}
 
int main(){
    int N, K;
    cin >> N >> K;
 
    // Aには全部入れて、Apos, Anegはそれぞれ正と負の値のみ入れる。全て絶対値で管理。
    vector<int64_t> A, Apos, Aneg;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        A.push_back(abs(a));
        if(a > 0) Apos.push_back(a);
        if(a < 0) Aneg.push_back(abs(a));
    }
    int szp = Apos.size(), szn = Aneg.size();
 
    int64_t ans = 1;
 
    if(szp + szn/2*2 >= K && (K%2 == 0 || szp > 0)){
        // 正にできる場合：絶対値を大きくしたい
        sort(Apos.rbegin(), Apos.rend());
        sort(Aneg.rbegin(), Aneg.rend());
        // Kが奇数ならまず正側の最大値を1個使う
        if(K%2) ans = Apos[0];
        // 正負それぞれで絶対値の大きいものから2個ずつペアにして、大きいものから使う
        vector<int64_t> V;
        for(int i=K%2; i+1<szp; i+=2) V.push_back(Apos[i]*Apos[i+1]);
        for(int i=0; i+1<szn; i+=2) V.push_back(Aneg[i]*Aneg[i+1]);
        sort(V.rbegin(), V.rend());
        for(int i=0; i<K/2; i++) mul(ans, V[i] % MOD);
    }else{
        // 正にできない場合：絶対値を小さくしたい
        // 全部混ぜて絶対値の小さいものから使う
        sort(A.begin(), A.end());
        for(int i=0; i<K; i++) mul(ans, A[i]);
        ans = (MOD-ans) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8416
#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>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
}c(200005);


//m^n
mint f(int m, int n) {
	if (0 == n) {
		return 1;
	}
	mint x = f(m, n / 2);
	x *= x;
	if (1 == n % 2) {
		x *= (mint)m;
	}
	return x;
}
// nCa
mint choose(int n, int a) {
	mint x = 1;
	mint y = 1;
	for (int m = 0; m < a; ++m) {
		x *= (mint)(n - m);
		y *= (mint)(a - m);
	}
	return x / y;
}
// nPk
mint nPk(int n, int a) {
	mint ret = choose(n, a);
	for (int n = 1; n <= a; ++n) {
		ret *= n;
	}
	return ret;
}


int main() {
	/*
	偶数 2N
	・N,N,0
	・N,x,y (x,y != 0)
	・N + 1 以上,x,y
	奇数 2N+1
	・N + 1 以上,x,y
	をそれぞれ３倍。
	*/

	int N;
	cin >> N;
	vector<int>A(N);
	int sum = 0;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		sum += A[i];
	}
	mint ans = 1;
	for (int i = 0; i < N; ++i) {
		ans *= 3;
	}
	vector<vector<mint>> dp(N + 1, vector<mint>(2 * sum + 1));
	dp[0][0] = 1;
	vector<vector<mint>> dp2(N + 1, vector<mint>(2 * sum + 1));
	dp2[0][0] = 1;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j <= sum; ++j) {
			dp[i + 1][j + A[i]] += dp[i][j];
			dp[i + 1][j] += dp[i][j] * 2;

			dp2[i + 1][j + A[i]] += dp2[i][j];
			dp2[i + 1][j] += dp2[i][j];
		}
	}

	for (int i = sum / 2 + 1; i <= sum; ++i) {
		ans -= mint(3)*dp[N][i];
	}
	if (0 == sum % 2) {
		ans -= (mint)3 * dp2[N][sum / 2];
		ans -= (mint)3 * (dp[N][sum / 2] - (mint)2 * dp2[N][sum / 2]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 852096
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;

    vector<vector<int>> a(n, vector<int>(m));
    vector<int> b(m);
    vector<int> c(n, 0);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> a[i][j];
        }
    }

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

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            c[i] += a[i][j] * b[j];
        }
    }

    for (int i = 0; i < n; i++)
    {
        cout << c[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3176
def knapsack_weight(single=True):
    """
    重さが小さい時のナップサックDP
    :param single: True = 重複なし
    """
    """ dp[weight <= W] = 重さ上限を固定した時の最大価値 """
    dp_min = 0  # 総和価値の最小値
    dp = [dp_min] * (W + 1)

    for item in range(N):
        S = range(W, weight_list[item] - 1, -1)
        for weight in S:
            if dp[weight] < dp[weight - weight_list[item]] + price_list[item]:
                dp[weight] = dp[weight - weight_list[item]] + price_list[item]
    return dp[W]

import sys
input = sys.stdin.readline  

N, W = map(int, input().split())                                # N: 品物の種類 W: 重量制限
 
price_list = []
weight_list = []
for _ in range(N):
    weight, price = map(int, input().split())
    price_list.append(price)
    weight_list.append(weight)
 
print(knapsack_weight(single=True))


Measured memory_bytes: 65932
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)



#define rrep(i,a,b) for(int i=a;i>=b;i--)
int N, M, A[101010], B[101010];
int Q, V[101010], D[101010], C[101010];
int ans[101010];
//-----------------------------------------------------------------------------------
vector<int> E[101010];
void dfs(int cu, int d, int c, int pa = -1) {
	ans[cu] = c;
	if (d == 0) return;

	for (int to : E[cu]) if (to != pa) {
		dfs(to, d - 1, c, cu);
	}
}
void partial() {
	rep(i, 0, M) {
		E[A[i]].push_back(B[i]);
		E[B[i]].push_back(A[i]);
	}
	rep(i, 0, Q) dfs(V[i], D[i], C[i]);
}
//-----------------------------------------------------------------------------------
pair<int,int> dp[101010][11];
void sol() {
	rep(i, 0, Q) {
		dp[V[i]][D[i]] = { i + 1, C[i] };
	}

	rrep(d, 10, 1) {
		rep(v, 1, N + 1) dp[v][d - 1] = max(dp[v][d - 1], dp[v][d]);
		rep(i, 0, M) {
			int a = A[i], b = B[i];
			dp[a][d - 1] = max(dp[a][d - 1], dp[b][d]);
			dp[b][d - 1] = max(dp[b][d - 1], dp[a][d]);
		}
	}

	rep(i, 1, N + 1) ans[i] = dp[i][0].second;
}
//-----------------------------------------------------------------------------------
int main() {
	cin >> N >> M;
	rep(i, 0, M) scanf("%d%d", &A[i], &B[i]);
	cin >> Q;
	rep(i, 0, Q) scanf("%d%d%d", &V[i], &D[i], &C[i]);

	//partial();
	sol();
	
	rep(i, 1, N + 1) printf("%d\n", ans[i]);
}

Measured memory_bytes: 14080
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
 
  int64_t x,a,b;
  cin>>x>>a>>b;

  if(abs(x-a)>abs(x-b))
    cout<<"B"<<endl;
  else
    cout<<"A"<<endl;

	return 0;
}

Measured memory_bytes: 3588
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    lint n, k, s;
    cin >> n >> k >> s;

    vector<lint> a(n);
    rep(i, k){
        a[i] = s;
    }
    REP(i, k, n){
        a[i] = s == 1000000000LL ? s-1LL : s+1LL;
    }

    rep(i, n){
        if(i) cout << ' ';
        cout << a[i];
    }

    cout << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;


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


int main() {
  int N;cin >> N;
  int K;cin >> K;
  vector<int> h(N);REP(i,N) cin >> h[i];
  vector<int> dp(N,INF);
  dp[0] = 0;
  FOR(i,1,N){
    FOR(j,max(i-K,0),i){
      dp[i] = min (dp[i],dp[j] +abs(h[j]-h[i]));
    }
  }
  cout << dp [N-1] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const ll M=2e5+5;
std::vector<ll> vtr[M];
ll lvl[M];
ll o,e;
void dfs(ll x,ll p=-1,ll l=0)
{
	lvl[x]=l;
	if(l%2)
		o++;
	else
		e++;
	for(auto u:vtr[x])
	{
		if(u!=p)
		{
			dfs(u,x,l+1);
		}
	}
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n;
	cin>>n;
	for(ll i=1;i<n;i++)
	{
		ll u,v;
		cin>>u>>v;
		vtr[u].pb(v);
		vtr[v].pb(u);
	}
	dfs(1);
	std::vector<ll> v[3];
	for(ll i=1;i<=n;i++)
		v[i%3].pb(i);
	ll c[3];
	memset(c,0,sizeof(c));
	if(o<=n/3)
	{
		for(ll i=1;i<=n;i++)
		{
			if(lvl[i]%2)
			{
				cout<<v[0][c[0]]<<" ";
				c[0]++;
			}
			else
			{
				if(c[1]<sz(v[1]))
				{
					cout<<v[1][c[1]]<<" ";
					c[1]++;
				}
				else if(c[2]<sz(v[2]))
				{
					cout<<v[2][c[2]]<<" ";
					c[2]++;
				}
				else
				{
					cout<<v[0][c[0]]<<" ";
					c[0]++;
				}
			}
		}
		cout<<"\n";
		return 0;
	}
	if(e<=n/3)
	{
		for(ll i=1;i<=n;i++)
		{
			if(lvl[i]%2==0)
			{
				cout<<v[0][c[0]]<<" ";
				c[0]++;
			}
			else
			{
				if(c[1]<sz(v[1]))
				{
					cout<<v[1][c[1]]<<" ";
					c[1]++;
				}
				else if(c[2]<sz(v[2]))
				{
					cout<<v[2][c[2]]<<" ";
					c[2]++;
				}
				else
				{
					cout<<v[0][c[0]]<<" ";
					c[0]++;
				}
			}
		}
		cout<<"\n";
		return 0;
	}
	for(ll i=1;i<=n;i++)
	{
		if(lvl[i]%2)
		{
			if(c[1]<sz(v[1]))
			{
				cout<<v[1][c[1]]<<" ";
				c[1]++;
			}
			else
			{
				cout<<v[0][c[0]]<<" ";
				c[0]++;
			}
		}
		else
		{
			if(c[2]<sz(v[2]))
			{
				cout<<v[2][c[2]]<<" ";
				c[2]++;
			}
			else
			{
				cout<<v[0][c[0]]<<" ";
				c[0]++;
			}
		}
	}
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 20588
#include <iostream>
int main() {
	int w, h, x, y, r;
	std::cin >> w >> h >> x >> y >> r;
	if (w >= x + r && h >= y + r && x + r > 0 && y + r > 0) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  string s,t;
  cin >> s >> t;
  rep(i,26) {
    string k = s;
    k += i+'a';
    if(k==t) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#define N 100000
#define SEN 2000000000

struct Point{
  int value;
  char gou;
};

struct Point L[N/2+2],R[N/2+2];
void merge (struct Point hi[],int n,int l,int m,int r);
void mergesort (struct Point hi[],int n,int l,int r);
int partition (struct Point hi[],int n,int l,int r);
void quicksort(struct Point hi[],int n,int l,int r);

int main(){
  int i,n,st;
  char hiii[10];
  struct Point hi[N],hii[N];
  int judge=1;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s %d",hiii,&st);
    hi[i].gou=hii[i].gou=hiii[0];
    hi[i].value=hii[i].value=st;
  }

  mergesort(hi,n,0,n);
  quicksort(hii,n,0,n-1);

  for(i=0;i<n;i++){
    if(hi[i].gou != hii[i].gou)
      judge=0;
  }

  if(judge==1)
    printf("Stable\n");
  else
    printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",hii[i].gou,hii[i].value);
  }

  return 0;
}
  
void merge (struct Point hi[],int n,int l,int m,int r){
  int s,t;
  int i=0,j=0,p;
  s=m-l;
  t=r-m;
  for(i=0;i<s;i++)
    L[i]=hi[l+i];
  for(i=0;i<t;i++)
    R[i]=hi[m+i];
  
  L[s].value=R[t].value=SEN;

  i=j=0;
  
  for (p=l;p<r;p++){
    if (L[i].value<=R[j].value){
      hi[p]=L[i++];
    }else{
      hi[p]=R[j++];
    }
  }
}

void mergesort (struct Point hi[],int n,int l,int r){
  int m;
  if (l+1<r){
    m=(l+r)/2;
    mergesort(hi,n,l,m);
    mergesort(hi,n,m,r);
    merge(hi,n,l,m,r);
  }
}

int partition (struct Point hi[],int n,int l,int r){
  int i,j;
  struct Point x,q;
  x=hi[r];
  i=l-1;

  for(j=l;j<r;j++){
    if(hi[j].value<=x.value){
      i++;
      q=hi[i];
      hi[i]=hi[j];
      hi[j]=q;
    }
  }
  q=hi[i+1];
  hi[i+1]=hi[r];
  hi[r]=q;

  return i+1;
}

void quicksort(struct Point hi[],int n,int l,int r){
  int a;
  if(l<r){
    a=partition(hi,n,l,r);
    quicksort(hi,n,l,a-1);
    quicksort(hi,n,a+1,r);
  }
}



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

int f(int m,vector<int> a){
    int ans = 0;
    rep(i,a.size()){
        ans += m%a[i];
    }
    return ans;
}

int main(){
    // 制約見て！！！デカかったらlong longにすること！
    int n;
    cin >> n;
    vector<int> a(n);
    int ans = 0;
    rep(i,n){
        cin >> a[i];
        ans += a[i]-1;
    }
    cout << ans<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <stack>
using namespace std;
typedef long long int lli;
const long long int MaxN=200005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	lli dp[MaxN];
	lli arr[MaxN];
	void solve(){
		lli N,i,j,p,q;
		cin>>N;
		for(i=1;i<=N;i++){
			cin>>arr[i];
		}	
		dp[1]=0;
		dp[2]=abs(arr[2]-arr[1]);
		for(i=3;i<=N;i++){
			dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
		}
		cout<<dp[N]<<"\n";
	}
int main(){
	//cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,j,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
	
}


Measured memory_bytes: 5132
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
    char a, b;
    cin >> a >> b;

    if(a == 'D') {
        cout << (b == 'H' ? "D" : "H") << '\n';
    }
    else {
        cout << b << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define sf scanf
#define pf printf
using namespace std;
#define ll long long
const int N=2e6+9;
const ll mod = 1e9+7;
map<ll,ll>m;
void slv()
{
}
ll pre[N];
int main()
{
    double d,t,s;
    cin>>d>>t>>s;
    double time = d/s;
    if(time <= t) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 3740
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
#define N 105
int n,h,w,a[N*N],map[N][N],now=1,tmp;
int main()
{
	scanf("%d%d%d",&h,&w,&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=h;i++)
	{
		tmp=i&1?1:w; 
		for(int j=1;j<=w;j++)
		{
			map[i][tmp]=now;
			a[now]--;
			if(!a[now]) now++;
			i&1?tmp++:tmp--;
		}
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<w;j++) printf("%d ",map[i][j]);
		printf("%d\n",map[i][w]);
	}
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#define N 200000
#define MIN -1000000000
int main(){

  int i, j, n, r[N], max=MIN, min, prof;

  scanf("%d",&n);

  scanf("%d",&r[0]);
  
  min = r[0];
  
  for(i=1;i<n;i++){
    scanf("%d",&r[i]);
    prof=r[i]-min;
    if(i==1||max<prof)max=prof;
    if(min>r[i])min=r[i];
  }
  printf("%d\n",max);
  
  return 0;
}

Measured memory_bytes: 1376
x,y = input().split()
a="ABCDEF"
count_x=0
count_y=0
count=0
for i in a:
    if i == x: count_x = count
    if i == y:count_y = count
    count+=1
if count_x<count_y : print("<")
elif count_x==count_y : print("=")
else : print(">")

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

typedef long long ll;
ll mod = 1000000007;

ll power(ll x, ll y)
{
    ll res = 1;
    x = x%mod;
    while (y)
    {
        if (y&1) res = ((res%mod)*(x%mod))%mod;

        y>>=1;
        x = ((x%mod)*(x%mod))%mod;
    }
    return res;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n, k;
    cin >> n >> k;
    ll arr[n];
    ll x;
    for(int i=0; i<n; i++) cin>>x, arr[i]=x;

    sort(arr,arr+n);

    ll ans=0;
    for(int i=0; i<n; i++){
        if(i<n-k) ans+=arr[i];
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	static StringBuffer buf = new StringBuffer();
    public static void main (String args[]){
    	Scanner str = new Scanner(System.in);
    	int a = str.nextInt();
    	int b = str.nextInt();
    	int c = str.nextInt();

    if(c < b){
    	    if(c <a){
    	    	if(a<b){
    	    	    sum(c,a,b);
				    System.out.println(buf);
    	    	}else{
    	    		sum(c,b,a);
				    System.out.println(buf);
    	    	}
    	    }else{
    	    	if(c<b){
    	    	    sum(a,c,b);
    	    	    System.out.println(buf);
    	    	}else{
    	    		sum(a,b,c);
    	    	    System.out.println(buf);
    	    	}
    	    }
    	}else{
    		if(a < b){
    			if(b<c){
    			   sum(a,b,c);
    	    	   System.out.println(buf);
    			}else{
    			   sum(a,c,b);
     	    	   System.out.println(buf);
    			}
    	    }else{
    	    	if(a<c){
    	    	sum(b,a,c);
    	    	System.out.println(buf);
    	    	}else{
    	    		sum(b,c,a);
        	    	System.out.println(buf);
    	    	}
    	    }
    	}
    }

    static StringBuffer sum (int a,int b,int c){

    	buf.append(a);
    	buf.append(" ");
    	buf.append(b);
    	buf.append(" ");
    	buf.append(c);
    	return buf;

    }

}

Measured memory_bytes: 26128
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

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

int main(){
    map<string, int> mp;
    mp["SUN"] = 7;
    mp["MON"] = 6;
    mp["TUE"] = 5;
    mp["WED"] = 4;
    mp["THU"] = 3;
    mp["FRI"] = 2;
    mp["SAT"] = 1;
    
    string s;
    cin >> s;
    
    
    cout << mp[s] << endl;
    
    

}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define For(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define sz(x) ((int)(x).size())
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef long long ll;
typedef unsigned long long ull;

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

  string s; cin>>s;
  s = "$"+s;
  bool ok = true;
  For(i,1,s.length()-1) {
    if(i&1) {
      if(s[i]=='R' || s[i]=='U'|| s[i]=='D') ;
      else ok = false;
    } else {
      if(s[i]=='L' || s[i]=='U'|| s[i]=='D') ;
      else ok = false;
    }
  }
  cout<<(ok?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n;i++)
int main(void) {
	int n, a[100], b[100], sum = 0;cin >> n;
	rep(i, n) cin >> a[i];
	rep(i, n) {
		cin >> b[i];
		if (a[i] - b[i] > 0) {
			sum += a[i] - b[i];
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
def toSmall(word):
    res = ""
    for c in word:
        if(ord('A') <= ord(c) <= ord('Z')):
            res += chr(ord(c) - ord('A') + ord('a'))
        else:
            res += c
    return res

w = toSmall(input())
ans = 0

while True:
    s = input()
    if s == "END_OF_TEXT":
        break

    s = list(map(str, s.split()))
    for x in s:
        if toSmall(x) == w:
            ans += 1

print(ans)


Measured memory_bytes: 5556
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;

int main()
{
	int x,a,b;
	while(cin>>x>>a>>b){
		if (abs(a-x)>abs(b-x)){
			cout<<"B"<<endl;
		}
		else
			cout<<"A"<<endl;
	}
	return 0;
}

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

int main(){
  int N,B,c=0;
  vector<vector<int>> A(3,vector<int>(3));
  for(int i=0; i<3;i++){
    for(int j=0;j<3;j++)
      cin>> A.at(i).at(j);
  }

  cin>>N;
  for(int i=0;i<N;i++){
    cin>> B;
    for(int j=0 ;j<3;j++){
     for(int l=0;l<3;l++){
       if(A.at(j).at(l)==B)
          A.at(j).at(l)=0;
    
       }
      
    }
  }

  for(int i=0;i<3;i++){
    if((A.at(i).at(0)==A.at(i).at(1))&&(A.at(i).at(0)==A.at(i).at(2))){
      c=1;
      break;
    }
    if((A.at(0).at(i)==A.at(1).at(i))&&(A.at(0).at(i)==A.at(2).at(i))){
      c=1;
      break;
    }
  }
  if((A.at(0).at(0)==A.at(1).at(1))&&(A.at(0).at(0)==A.at(2).at(2)))
    c=1;
  if((A.at(0).at(2)==A.at(1).at(1))&&(A.at(0).at(2)==A.at(2).at(0)))
    c=1;

  if(c==1)
    cout << "Yes"<< endl;
  else
    cout << "No"<< endl;

}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;
const double PI=3.14159265359;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n,k;
    cin>>n>>k;
    long long ans=0;
    if(!k){
        cout<<(long long)n*n;
        return 0;
    }
    
    for(int b=k+1; b<=n; b++){
        int t=b-k;
        int left=k, right=b-1;
        for(int shift=0; left<=n && right<=n; shift++){
            if(left<=n && right<=n){
                ans+=t;
                left+=b, right+=b;
            }
        }
        if(left<=n && right>n){
            ans+=n-left+1;
        }
    }
    cout<<ans;
   
    return 0;
}

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

int main(){
    int x,y,z;
    cin >> x >> y >> z;
    cout << (x-z)/(y+z) << endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
p = list(map(int, input().split()))

sum_p = 0
sum_list = []
sum_list.append(sum_p)
for p_element in p:
    sum_p += p_element 
    sum_list.append(sum_p)

sum = 0
start = 0
for i in range(N-K+1):
    if sum < sum_list[i+K]-sum_list[i]:
        sum = sum_list[i+K]-sum_list[i]
        start = i

answer = 0
for i in range(K):
    answer += (1+p[start+i])/2
print(answer)

Measured memory_bytes: 75912
let N = stdin.ReadLine() |> int
let B = stdin.ReadLine().Split() |> Array.map int

if B.Length = 1 then
    B.[0]*2 |> stdout.WriteLine
else
(
    B
    |> Array.pairwise
    |> Array.fold (fun acc (a, b) -> acc + min a b) B.[0]
) + B.[N-2]
|> stdout.WriteLine

Measured memory_bytes: 13396
from bisect import bisect_left
n = int(input())
l = list(map(int,input().split()))
l.sort()
 
ans = 0
for i in range(n-2):
  for j in range(i+1,n-1):
   ans += bisect_left(l,l[i] + l[j]) - j - 1
print(ans)

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

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

  int holiday;
  if (S == "SUN") { holiday = 7; }
  else if (S == "MON") { holiday = 6; }
  else if (S == "TUE") { holiday = 5; }
  else if (S == "WED") { holiday = 4; }
  else if (S == "THU") { holiday = 3; }
  else if (S == "FRI") { holiday = 2; }
  else if (S == "SAT") { holiday = 1; }
  cout << holiday << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<stack>
#include<vector>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
const ll inf =1e17;
#define scn(a) scanf("%d",&a)
#define scd(a) scanf("%lf",&a)
#define scl(a) scanf("%lld",&a)
#define ptf(a) printf("%d\n",&a)
#define mes(a,b) memset(a,b,sizeof(a))
#define fon(s,n) for(int i=s;i<=n;i++)
#define range(i,a,b) for(int i=a;i<=b;++i)
#define rerange(i,a,b) for(int i=a;i>=b;--i)
//#define N 100010
const int S=20;
ll gcd(ll a,ll b) { return b>0 ? gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll q_pow(ll a,ll b,ll mod)
{
	ll ans=1,res=a;
	while(b){
		if(b&1) ans=ans*res%mod;
		res=res*res%mod;
		b>>=1;
	}
	return ans%mod;
}
 bool cmp(const pair<string,int> &p1, const pair<string,int> &p2) {
    return p1.second > p2.second;
}

int main()
{
    int k,a,b;
    scn(k);
    scn(a);scn(b);
    for(int i=a;i<=b;i++){
        if(i%k==0) {
            printf("OK\n");
            return 0;
        }
    }
    printf("NG\n");
    return 0;
}

Measured memory_bytes: 3772
a, b, c, k = gets.split(" ").map(&:to_i)
sum = 0
if k < a
  sum = k
  puts sum
  exit
else
  sum = a
  k = k - a
end

if k < b
  puts sum
  exit
else
  k = k - b
end

if k < c
  sum = sum + (k * -1)
  puts sum
else
  sum = sum + (c * -1)
  puts sum
end

Measured memory_bytes: 14344
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 50;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
#define asn ans
bool dbg = false;

int X, Y, A, B, C;
vi p, q, r;
//vector<pair<int, int>> V;
vector<int> V;

void solve() {
    sort(all(p), greater<int>());
    sort(all(q), greater<int>());
    sort(all(r), greater<int>());
    FOR(i, 0, X) {
        V.eb(p[i]);
    }
    FOR(i, 0, Y)
    V.eb(q[i]);

    sort(all(V), greater<int>());
    FOR(X + Y - 1)
    V[i + 1] += V[i];

    FOR(C - 1)
    r[i + 1] += r[i];
    int ans = 0;
    for (int i = X + Y - 1; i >= 0; i--) {

        int res = X + Y - 2 - i;
        if (res >= C) {
            break;
        }
        if (res < 0)
            chmax(ans, V[i]);
        else
            chmax(ans, V[i] + r[res]);
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> X >> Y >> A >> B >> C;
    p.resize(A);
    q.resize(B);
    r.resize(C);
    FOR(A)
    cin >> p[i];
    FOR(B)
    cin >> q[i];
    FOR(C)
    cin >> r[i];


    solve();
    return 0;
}


Measured memory_bytes: 4852
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
 
public class Main implements Runnable {
	
    public static void main(String[] args) {
    	new Thread(null, new Main(), "", 1 * 1024 * 1024).start();
    }
    
    public void run() {
        FastScanner sc = new FastScanner();
        
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = sc.nextIntArray(n);
        
        int gcd = a[0];
        int max = a[0];
        for(int i=1;i<n;i++){
        	gcd = gcd(gcd,a[i]);
        	max = Math.max(max,a[i]);
        }
        
        if(k%gcd==0 && max>=k){
        	System.out.println("POSSIBLE");
        }
        else{
        	System.out.println("IMPOSSIBLE");
        }
        
    }
    
	//2整数の最大公約数を求める。（ユークリッドの互除法）
	 static int gcd(int a, int b){
	     if(b == 0){
	    	 return a;
	     }
	     return gcd(b, a%b);
	}
 
}


class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
	public int[] nextIntArray(int n){
		int[] a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 24020
mNK = map(int, input().split())
lNK = list(mNK)

lSnk = [1 for i in range(lNK[0])]

for i in range(lNK[1]):
    d = int(input())
    mSwt = map(int, input().split())
    lSwt = list(mSwt)
    for s in lSwt:
        lSnk[s - 1] = 0

ans = sum(lSnk)
print(ans)

Measured memory_bytes: 9192
#include"bits/stdc++.h"
using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> l(N);
	for (int i = 0;i < N;++i) {
		cin >> l[i];
	}
	sort(l.begin(), l.end());
	int ans = 0;
	for (int i = 0;i < K;++i) {
		ans += l[l.size() - 1 - i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2*10**5+100)

MAX = 2*10**5+100
MOD = 10**9+7
fact = [0]*MAX #fact[i]: i!
inv = [0]*MAX #inv[i]: iの逆元
finv = [0]*MAX #finv[i]: i!の逆元
fact[0] = 1
fact[1] = 1
finv[0] = 1
finv[1] = 1
inv[1] = 1
    
for i in range(2, MAX):
    fact[i] = fact[i-1]*i%MOD
    inv[i] = MOD-inv[MOD%i]*(MOD//i)%MOD
    finv[i] = finv[i-1]*inv[i]%MOD

def C(n, r):
    if n<r:
        return 0
    if n<0 or r<0:
        return 0
    return fact[n]*(finv[r]*finv[n-r]%MOD)%MOD

def dfs1(v, pv):
    res = 1
    M = 0
    
    for nv in G[v]:
        if nv==pv:
            continue
        
        num, res2 = dfs1(nv, v)
        res *= finv[num]*res2
        res %= MOD
        M += num
    
    res *= fact[M]
    res %= MOD
    st[v] = res
    chi[v] = M+1
    
    return M+1, res
    
def dfs2(v, pv):
    res = rt[pv]*fact[chi[v]]*fact[N-chi[v]-1]*pow(st[v], MOD-2, MOD)
    res *= finv[N-chi[v]]
    res %= MOD
    
    for nv in G[v]:
        if nv==pv:
            continue
        
        res *= finv[chi[nv]]*st[nv]
        res %= MOD
    
    rt[v] = res
    
    for nv in G[v]:
        if nv==pv:
            continue
        
        dfs2(nv, v)
    
N = int(input())
G = [[] for _ in range(N)]

for _ in range(N-1):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

st = [-1]*N
rt = [-1]*N
chi = [-1]*N
dfs1(0, -1)
rt[0] = st[0]

for nv in G[0]:
    dfs2(nv, 0)

for rt_i in rt:
    print(rt_i)


Measured memory_bytes: 144108