akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define mod 1e9 +7;
typedef long long ll;
typedef vector<ll> vll;
const double phi = (1 + sqrt(5)) / 2;
const double phi_ = (1 - sqrt(5)) / 2;
ll fib(ll n){
    double res = pow(phi, n+1) - pow(phi_, n+1);
    return res / sqrt(5);
}
ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}
ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}
string to_bin_string(ll n){
    stringstream ss;
    ss << bitset<8>(n); //任意の桁数<m>
    string s = ss.str();
    return s;
}
int main()
{
    int n; cin >> n;
    vll a(n);
    rep(i,n)cin >> a[i];
    ll s = abs(a[0]) + abs(a[n-1]);
    REP(i,1,n)s += abs(a[i-1] - a[i]);

    cout << s - abs(a[0]) - abs(a[0] - a[1]) + abs(a[1]) << endl;
    REP(i,1,n-1)cout << s - abs(a[i-1] - a[i]) - abs(a[i] - a[i+1]) + abs(a[i-1] - a[i+1]) << endl;
    cout << s - abs(a[n-1]) - abs(a[n-1] - a[n-2]) + abs(a[n-2]) << endl;
    return 0;
} 

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int main()
{
    string a, b;
    cin >> a >> b;
    int ans = 0;
    for (int i = 0; i < a.size(); i++){
        if (a[i] != b[i]) ++ans;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3884
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#define MP make_pair
using ll = long long;
using namespace std;

ll mod = pow(10,9)+7;

ll kai(int n)
{
  ll ans=1;
  for(int i=0; i < n; i++){
    ans *= n-i;
    ans %= mod;
  }
  return ans;
}
int main()
{
  int N,M;
  cin >> N >> M;
  if(abs(N-M) >= 2)
    cout << 0 << endl;
  else if(N==M)
    cout << (kai(N)*kai(M))*2 % mod << endl;
  else
    cout << kai(N)*kai(M) % mod << endl;
  return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<long long>::max();
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, s, t, q, ans = INF, sum, last, cnt, a[2][100000];
struct Edge { LL to, cost; };
vector<Edge>vec[100000];
string str;
bool f = 0;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n >> m;
	ans = min(n, m);
	if (n % 3 == 0 || m % 3 == 0) {
		cout << 0 << endl;
	}
	else {
		for (LL i = 1; i < n; i++) {
			LL num[3];
			num[0] = i*m;
			num[1] = (LL)(m / 2)*(n - i);
			num[2] = (LL)((m + 1) / 2)*(n - i);
			ans = min(ans, max({ num[0], num[1], num[2] }) - min({ num[0], num[1], num[2] }));
		}
		for (LL i = 1; i < m; i++) {
			LL num[3];
			num[0] = i*n;
			num[1] = (LL)(n / 2)*(m - i);
			num[2] = (LL)((n + 1) / 2)*(m - i);
			ans = min(ans, max({ num[0], num[1], num[2] }) - min({ num[0], num[1], num[2] }));
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
int n,i,j,S[13]={0},H[13]={0},C[13]={0},D[13]={0};
char ch;
int main(){
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c",&ch);
    if(ch=='S'){
      scanf(" %d",&j);
      S[j-1]+=1;
    } else if(ch=='H'){
      scanf(" %d",&j);
      H[j-1]+=1;
    } else if(ch=='C'){
      scanf(" %d",&j);
      C[j-1]+=1;
    } else if(ch=='D'){
      scanf(" %d",&j);
      D[j-1]+=1;
    }
  }
  for(i=0;i<13;i++){
    if(S[i]==0){
      printf("S %d\n",i+1);
    }
  }
  for(i=0;i<13;i++){
    if(H[i]==0){
      printf("H %d\n",i+1);
    }
  }
  for(i=0;i<13;i++){
    if(C[i]==0){
      printf("C %d\n",i+1);
    }
  }
  for(i=0;i<13;i++){
    if(D[i]==0){
      printf("D %d\n",i+1);
    }
  }
  return 0;
}

Measured memory_bytes: 2684
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
ll def(ll X) {
	if (X % 4 == 3) {
		return 0;
	}
	else if (X % 4 == 0) {
		return X;
	}
	else if (X % 4 == 1) {
		return X ^ (X - 1);
	}
	else if (X % 4 == 2) {
		return X + 1;
	}
}
int main() {
	ll A, B;
	cin >> A >> B;
	if (A != 0 && B != 0) {
		cout << (def(B) ^ def(A - 1)) << endl;
	}
	else if (A == 0 && B == 0) {
		cout << 0 << endl;
	}
	else {
		cout << def(B) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const long long INF = INT_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, cnt = 0, w, h;
string s;
vector<ll> v;
vector<ll> v1;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
set<ll> st;
map<char, ll> mp;

/*--------------------template--------------------*/


int main()
{
	while(1)
	{
		sum++;
		cin >> n;
		if (n == 0) break;
		cout << "Case "<<sum<<": " << n << endl;
	}
}

Measured memory_bytes: 3064
//abc179_b.cpp
//Sat Sep 19 21:01:49 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

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

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

	int c = 0;
	int flag = 0;
	rep(i,n){
		int d1,d2;
		cin >> d1 >> d2;
		if (d1==d2){
			c++;
			if (c==3){
				flag = 1;
			}
		}else {
			c = 0;
		}
	}

	if (flag){
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
//	printf("%.4f\n",ans);
}


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

int main() {
  string s;
  cin >> s;
  
  int ans = 0;
  if (s == "SUN") ans = 7;
  if (s == "MON") ans = 6;
  if (s == "TUE") ans = 5;
  if (s == "WED") ans = 4;
  if (s == "THU") ans = 3;
  if (s == "FRI") ans = 2;
  if (s == "SAT") ans = 1;
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define MAX_N (40)
#define MAX_A (10)
#define MAX_B (10)
#define INF (1 << 30)

using namespace std;

int dp[MAX_N + 1][MAX_N * MAX_A + 1][MAX_N * MAX_B + 1];

// self study
// time taken 40min
int main(int argc, char *argv[]) {
  // read inputs
  int N, Ma, Mb, as[MAX_N], bs[MAX_N], cs[MAX_N];
  scanf("%d %d %d", &N, &Ma, &Mb);
  for (int i = 0; i < N; i++) {
    scanf("%d %d %d", &as[i], &bs[i], &cs[i]);
  }

  // solve dp
  // dp[k+1][i][j] : minimum cost to make (i, j) using items 0 to k
  for (int i = 0; i <= N * Ma; i++) {
    for (int j = 0; j <= N * Mb; j++) {
      dp[0][i][j] = INF;
    }
  }
  dp[0][0][0] = 0;
  for (int k = 0; k < N; k++) {
    const int a = as[k], b = bs[k], c = cs[k];
    for (int i = 0; i <= N * Ma; i++) {
      for (int j = 0; j <= N * Mb; j++) {
        const int i2 = i - a, j2 = j - b;
        if (i2 >= 0 && j2 >= 0) {
          dp[k + 1][i][j] = min(dp[k][i][j], dp[k][i2][j2] + c);
        } else {
          dp[k + 1][i][j] = dp[k][i][j];
        }
        // printf("%d ", dp[k + 1][i][j]);
      }
    }
  }

  int min_cost = INF;
  for (int k = 1; k <= N; k++) {
    min_cost = min(min_cost, dp[N][k * Ma][k * Mb]);
  }
  if (min_cost < INF) {
    printf("%d\n", min_cost);
  } else {
    printf("-1\n");
  }

  return 0;
}


Measured memory_bytes: 25856
# coding: utf-8
# Your code here!

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

n = int(input())
a = [int(i) for i in readline().split()]

def binarysearch(ok,ng,isOK): #二分探索
    while(abs(ok-ng) > 1):
        mid = (ok + ng)//2
        if isOK(mid): ok = mid
        else: ng = mid
    return ok

from collections import Counter
def isOK(x): #中央値はx以上？
    c = [1 if i >= x else -1 for i in a]
    res = Counter([0])
    now = 0
    less = 1
    ans = 0
    for i in range(n):
        if c[i] > 0:
            less += res[now+1]
        else:
            less -= res[now]
        now += c[i]
        ans += less
        less += 1
        res[now] += 1
    return ans >= (n*(n+1)//2+1)//2      


ans = binarysearch(0,10**9+1,isOK)
print(ans)



Measured memory_bytes: 131340
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int N = 2e5 + 5;
int n,m,k;

using ll = long long;
const int mod = 1e9 + 7;
int fac[N], finv[N];

ll quick_pow(ll a, ll b) {
    ll res = 1;
    a %= mod;
    while (b) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

void init_fac_mod(int to){
    //only when mod is prime
    fac[0] = finv[0] = 1;
    for(int i = 1; i <= to; ++i)
        fac[i]=(ll)fac[i-1]*i%mod;
    finv[to] = quick_pow(fac[to], mod-2);
    for(int i = to-1; i; --i)
        finv[i] = (ll)finv[i+1]*(i+1)%mod;
}

int c(int n, int m){
    //n!/(m!(n-m)!)
    return (ll)fac[n] * finv[m] % mod * finv[n - m]% mod;
}



int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>m>>k;
    
    
    ll d = 0;
    for (int i = 1; i < n; i++){
        d += (ll)i*(n-i)%mod*m%mod*m%mod;
        d%= mod;
    }
    
    for (int i = 1; i < m; i++){
        d += (ll)i*(m-i)%mod*n%mod*n%mod;
        d %= mod;
    }
    
    init_fac_mod(n*m-2);
    cout<<d*c(n*m-2, k-2)%mod<<endl;
    
    
    
    
    
    return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    long long N;
    long long temp;
    long long ans=0;
    vector<long long> A, B, C;

    cin >> N;

    for(long long i=0; i<N; ++i) {
        cin >> temp;
        A.push_back(temp);
    }
    for(long long i=0; i<N; ++i) {
        cin >> temp;
        B.push_back(temp);
    }
    for(long long i=0; i<N; ++i) {
        cin >> temp;
        C.push_back(temp);
    }

    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());

    vector<long long> dp;
    dp.resize(N+1);
    dp[N]=0;

    long long j=0;
    for(long long i=0; i<N; ++i){
        while(j<N && B[i]>=C[j]) ++j;
        dp[i]=N-j;
    }

    for(long long i=0; i<N; ++i) {
        dp[N-i-1]+=dp[N-i];
    }

    j=0;
    for(long long i=0; i<N; ++i) {
        while(j<N && A[i]>=B[j]) ++j;
        ans+=dp[j];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <unordered_map>
using namespace std;

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  for (int i = a; i <= min(a + k - 1, b); i++) {
    cout << i << endl;
  }
  for (int i = max(a, b - k + 1); i <= b; i++) {
    if (i <= a + k - 1) { continue; }
    cout << i << endl;
  }
}


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

using namespace std;

int djs[3000];

int main () {
  int h, w; 
  cin >> h >> w;
  vector<string> s(h);
  for (int i = 0; i < h; ++i) {
    cin >> s[i];
  }

  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j)
      if (s[i][j] == '#' && (i == 0 || s[i-1][j] == '.') && (i == (h-1) || s[i+1][j] == '.') && (j == 0 || s[i][j-1] == '.') && (j == w-1 || s[i][j+1] == '.')) {
        cout << "No\n";
        return 0;
      }
  cout << "Yes\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 10000
#define NIL -1

struct Node {int p, l, r;};
struct Node T[MAX];
int N;

void preParse(int u ){
    if (u == NIL) return;
    printf(" %d", u);
    preParse(T[u].l);
    preParse(T[u].r);
}

void inParse(int u) {
    if (u == NIL) return;
    inParse(T[u].l);
    printf(" %d", u);
    inParse(T[u].r);
}

void postParse(int u) {
    if (u == NIL) return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d", u);
}

int main() {
    int i, v, l, r, root;
    scanf("%d", &N);
    for (i = 0; i < N; i++) {
        T[i].p = NIL;
    }

    for (i = 0; i < N; i++) {
        scanf("%d %d %d", &v, &l, &r);
        T[v].l = l;
        T[v].r = r;
        if (l != NIL) T[l].p = v;
        if (r != NIL) T[r].p = v;
    }

    for (i = 0; i < N; i++) if (T[i].p == NIL) root = i;

    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");
    return 0;
}


Measured memory_bytes: 2760
# Problem - 文字のカウント

# input
S = ''
while True:
    try:
        line = input().lower()
        S += line
    except EOFError:
        break

# count
S_dic = {}
for i in range(26):
    tmp = chr(ord('a') + i)
    S_dic[tmp] = 0
for i in range(len(S)):
    c = S[i]
    if c>='a' and c<='z':
        S_dic[c] += 1

# output
for k, item in S_dic.items():
    print("%s : %d"%(k, item))



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

#define Read()            freopen("in.txt", "r", stdin)
#define Write()           freopen("out.txt", "w", stdout)
#define min3(a, b, c)     min(a, min(b, c))
#define max3(a, b, c)     max(a, max(b, c))
#define TC(i, a, b)       for(int i = a; i<=b; i++)
#define FOR(i, a, b)      for(int i = a; i<b; i++)
#define ROF(i, a, b)      for(int i = a; i>=b; i--)
#define MEM(a, x)         memset(a, x, sizeof(a))
#define SQR(x)            ((x)*(x))
#define valid(x, s, e)    (x>=s && x<=e)
#define sz(a)             int((a).size()) 
#define all(c)            (c).begin(),(c).end() 
#define tr(c,i)           for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define present(c,x)      ((c).find(x) != (c).end()) 
#define cpresent(c,x)     (find(all(c),x) != (c).end()) 
#define pb                push_back
#define MAX               1000000000
#define ff                first
#define ss                second
#define sf             	  scanf
#define pf 	              printf

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

using namespace std;


typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii;
typedef long long LL;
typedef unsigned long long ULL;

int main(int argc, char const *argv[])
{
	//Read();
	//Write();
	string x;
	cin>>x;
	x[3] = '8';
	cout<<x<<endl;
}

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

using namespace std;

const int mod = 1007050321;
const int base = 521;
const int N = 2e5 + 5;
const int MOD = 1e9 + 7;
const int inf = 2e9;

string s,l,r;
int n;

bool check (string t) {
    string S = t;
    reverse(S.begin(),S.end());
    for (int i = 0; i < S.size(); ++i)
        if (t[i] != S[i]) return 0;
    return 1;
}

int main() {
    ios_base :: sync_with_stdio(0),cin.tie(0),cout.tie(0);

    cin >> s;
    n = s.size();
    s = ' ' + s;
    l = "";
    r = "";

    for (int i = 1; i <= (n-1)/2; ++i) l = l + s[i];
    for (int i = (n+3)/2; i <= n; ++i) r = r + s[i];

    s.erase(0,1);
    if (check(s) && check(l) && check(r)) cout << "Yes";
    else cout << "No";
    return 0;
}


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

int main() {
  int n,k;
  cin>>n>>k;
  vector<int> sunuke(n,0);
  rep(i,k){
    int d;
    cin>>d;
    rep(j,d){
      int a;
      cin>>a;
      sunuke[a-1]++;
    }
  }
  int ans=0;
  rep(i,n) if(sunuke[i]==0) ans++;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    ll t1,t2;
    ll a1,a2;
    ll b1,b2;
    cin>>t1>>t2>>a1>>a2>>b1>>b2;
    ll judge = t1*(a1-b1) + t2*(a2-b2);
    if( judge == 0 ){
	cout<<"infinity"<<endl;
	return 0;
    }
    if( judge < 0 ){
	swap( a1 , b1 );
	swap( a2 , b2 );
    }
    ll s = 0;
    ll aa1 = a1*t1;
    ll bb1 = b1*t1;
    ll b = b1*t1 + b2*t2;
    ll res = 0;
    /*while( s <= b ){
	if( s + aa1 <= bb1 ) res++;
	s += abs(judge);
    }*/
    judge = abs(judge);
    ll dis = (b1-a1)*t1;
    res += ( dis / judge) *2;
 //   res++;
    if( dis <= 0 ){
	//cout<<"di"<<dis<<endl;
	cout<<0<<endl;
	return 0;
    }
    //res += ( ( a2 - b2 )*t2 - dis  )/judge;
    res += (dis%judge != 0 );
    //cout<<dis<<' '<<judge<<endl;
    cout<<max(res, 0ll)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;

ll y[10000005];

int main() {
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a),q(b),r(c);
    rep(i,a) cin >> p[i];
    rep(i,b) cin >> q[i];
    rep(i,c) cin >> r[i];
    sort(p.rbegin(),p.rend());
    sort(r.rbegin(),r.rend());
    sort(q.rbegin(),q.rend());

    vector<ll> s;
    for(int i = 0; i < x; i++) s.pb(p[i]);
    for(int i = 0; i < y; i++) s.pb(q[i]);
    for(int i = 0; i < c; i++) s.pb(r[i]);
    sort(s.rbegin(),s.rend());

    ll ans = 0;
    rep(i,x+y) ans += s[i];
    cout << ans << endl;
}


Measured memory_bytes: 9760
S = str(input())
import collections

Q = collections.deque()

for i in range (0, len(S)):
	if S[i] == 'B':
		if len(Q) >= 1:
			D = Q.pop()
	else:
		Q.append(S[i])

T = str()
while Q:
	V = Q.popleft()
	T=T+V
    
print(T)

Measured memory_bytes: 9360
import std.stdio;
import std.math;
import std.conv;

void main(){
	int n;
	scanf("%d", &n);
	int digit = log10(n.to!float).floor.to!int;
	if (digit == 0) {
		write(n);
	}
	else if (digit == 1) {
		write(9);
	}
	else if (digit == 2) {
		write(9 + (n-99));
	}
	else if (digit == 3) {
		write(9 + 900);
	}
	else if (digit == 4) {
		write(9 + 900 +  (n-9999));
	}
	else {
		write(9 + 900 + 90000);
	}
}


Measured memory_bytes: 256
#include <iostream>
#define MAX 10000
#define NIL -1 

using namespace std;

struct Node
{
	int parent;
	int left;
	int right;
}T[MAX];

void preparse(int u)
{
	if(u == NIL)
	{
		return ;
	}
	cout << " " << u;
	preparse(T[u].left);
	preparse(T[u].right);
}

void inparse(int u)
{
	if(u == NIL)
	{
		return ;
	}
	inparse(T[u].left);
	cout << " " << u;
	inparse(T[u].right);
}

void postparse(int u)
{
	if(u == NIL)
	{
		return ;
	}
	postparse(T[u].left);
	postparse(T[u].right);
	cout << " " << u;
}

int main()
{
	int n, i, u, left, right, r;
	cin >> n;
	for(i = 0; i < MAX; i++)
	{
		T[i].left = T[i].parent = T[i].right = NIL;
	}
	for(i = 0; i < n; i++)
	{
		cin >> u >> left >> right;
		T[u].left = left;
		T[u].right = right;
		T[left].parent = T[right].parent = u;
	}
	for(i = 0; i < n; i++)
	{
		if(T[i].parent == NIL)
		{
			r = i;
			break;
		}
	}
	
	cout << "Preorder" << endl;
	preparse(r);
	cout << endl;
	
	cout << "Inorder" << endl;
	inparse(r);
	cout << endl;
	
	cout << "Postorder" << endl;
	postparse(r);
	cout << endl;
	
	return 0;
}


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

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define MOD 1000000007

#define trace1(x)                    cout <<#x<<": "<<x<< endl;
#define trace2(x, y)                 cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)              cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)           cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;

typedef long long ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    ll i,j,n,m,l;
    cin>>n>>l;
    ll ans=n*l-n+((n*(n+1))/2);
    if(l<=0 && l>=-n+1)
    ans=ans;
    else
    {
        if(abs(l)<=abs(l+n-1))
        ans-=l;
        else
        ans-=(l+n-1);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
import math
import random
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
input = sys.stdin.readline
T =[int(i) for i in input().split()]
A =[int(i) for i in input().split()]
B =[int(i) for i in input().split()]
if (T[0] *A[0] +T[1] * A[1]) == (T[0] *B[0] +T[1] * B[1]):
    print("infinity")
elif A[0] > B[0] and (T[0] *A[0] +T[1] * A[1]) > (T[0] *B[0] +T[1] * B[1]):
    print(0)
elif A[0] < B[0] and (T[0] *A[0] +T[1] * A[1]) < (T[0] *B[0] +T[1] * B[1]):
    print(0)
else:
    adv = abs(T[0] *A[0]-T[0] *B[0])
    diff = abs((T[0] *A[0] +T[1] * A[1]) - (T[0] *B[0] +T[1] * B[1]))
    if adv%diff == 0:
        ans = (adv//diff) *2
    else:
        ans = (adv//diff) *2+1
    print(ans)

Measured memory_bytes: 67052
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;
using P = pair<int, int>;

// union find tree 型データ構造
class UnionFindTree {
  const std::size_t N_;              // 頂点数
  std::size_t species_;              // 相異なる集合の数
  std::vector<std::size_t> parent_;  // 親のindexを示す
  std::vector<std::size_t> sz_;      // 属する集合のサイズ(ただしrootのみが正確)

 public:
  explicit UnionFindTree(std::size_t);
  std::size_t root(std::size_t);
  std::size_t size(std::size_t);
  bool same(std::size_t, std::size_t);
  void unite(std::size_t, std::size_t);
  std::size_t variation();
};
// ctor．グラフの頂点数を引数にとる．
UnionFindTree::UnionFindTree(std::size_t n) : N_(n), species_(n) {
  parent_.reserve(N_);
  sz_.reserve(N_);
  for (std::size_t i = 0; i < N_; i++) {
    parent_[i] = i;
    sz_[i] = 1;
  }
}
// xの属する集合のrootを求める．
std::size_t UnionFindTree::root(std::size_t x) {
  if (parent_[x] == x) {
    return x;
  }
  return parent_[x] = root(parent_[x]);
}
// xの属する集合のサイズを返す
std::size_t UnionFindTree::size(std::size_t x) { return sz_[root(x)]; }
// xとyが同じ集合に属しているかどうかをbooleanで返す．
bool UnionFindTree::same(std::size_t x, std::size_t y) { return root(x) == root(y) ? true : false; }
// xとyが属する集合を統合する．
void UnionFindTree::unite(std::size_t x, std::size_t y) {
  x = root(x);
  y = root(y);
  if (x != y) {
    parent_[x] = y;
    sz_[y] += sz_[x];
    species_--;
  }
}
// uftに何種類の集合があるかを返す
std::size_t UnionFindTree::variation() { return species_; }

const int64_t INF = 1e18;  // 問題に合わせて適切に設定してね
struct edge {              // エッジの行き先と距離を保持するクラスというイメージ
  int64_t to, cost;        // costは適切にcolorと読み替えたりもできる．
};

int main() {
  int N;
  cin >> N;
  UnionFindTree uft(N);
  int xx[100000];
  int yy[100000];
  pair<int, int> xatlas[100001] = {};
  pair<int, int> yatlas[100001] = {};
  for (int i = 0; i < 100001; i++) {
    xatlas[i] = P(-1, 0);
    yatlas[i] = P(-1, 0);
  }
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    xx[i] = x;
    yy[i] = y;
    if (xatlas[x].first != -1) {
      uft.unite(i, xatlas[x].first);
      xatlas[x].second++;
    } else {
      xatlas[x] = P(i, 1);
    }
    if (yatlas[y].first != -1) {
      uft.unite(i, yatlas[y].first);
      yatlas[y].second++;
    } else {
      yatlas[y] = P(i, 1);
    }
  }
  // 集合内に何種類のx, y座標があるのか調べたい．
  P sz[100000] = {};
  int64_t ans = 0;
  map<int, set<int>> mpx;
  map<int, set<int>> mpy;
  for (int i = 0; i < N; i++) {
    int root = uft.root(i);
    mpx[root].insert(xx[i]);
    mpy[root].insert(yy[i]);
  }
  for (int i = 0; i < N; i++) {
    int64_t xsize = mpx[i].size();
    int64_t ysize = mpy[i].size();
    ans += xsize * ysize;
  }
  cout << ans - N << endl;
  return 0;
}

Measured memory_bytes: 28416
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,i=0,j,c=0,h[100010],a[100010],b[100010],ans=1;
    string s[200010];                                
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> s[i];
    }
    sort(s,s+n);
    for(i=0;i<n-1;i++)
    {
        if(s[i]!=s[i+1])
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 9856
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		Set<String> set = new HashSet<String>();
		int i = 0;
		for(i = 0; i < n; i++) {
			set.add(scan.next());
		}
		if(set.size() == 3) {
			System.out.println("Three");
		} else {
			System.out.println("Four");
		}
	}
}

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

using namespace std;

ifstream fin("fisier.in");
ofstream fout("fisier.out");

int v[2005];

int main(){
    int n,i,j,k,answer=0,ok;

    cin>>n;

    for(i=1;i<=n;i++)
        cin>>v[i];

    sort(v+1,v+n+1);

    for(i=1;i<=n;i++)
        for(j=i+1;j<=n;j++){
            ok=1;
            for(k=j+1;k<=n && ok;k++)
                if(!(v[i]+v[j]>v[k] && v[i]+v[k]>v[j] && v[j]+v[k]>v[i]))
                    ok=0;
                else
                    answer++;
        }

    cout<<answer;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

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

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

    queue<P> q;
    vector<vector<int>> dist(h, vector<int>(w, INF));
    auto update = [&](int y, int x, int v) {
        if(dist[y][x] != INF) return;
        dist[y][x] = v;
        q.push(P(y, x));
    };
    rep(i, h) {
        rep(j, w) {
            if(field[i][j] == '#') update(i, j, 0);
        }
    }
    while(!q.empty()) {
        int ny = q.front().first, nx = q.front().second;
        q.pop();
        rep(i, 4) {
            int nj = ny + dy[i], ni = nx + dx[i];
            if(nj >= h || nj < 0 || ni >= w || ni < 0) continue;
            if(field[nj][ni] == '#') continue;
            update(nj, ni, dist[ny][nx] + 1);
        }
    }
    int ans = 0;
    rep(i, h) {
        rep(j, w) {
            if(dist[i][j] == INF) continue;
            ans = max(ans, dist[i][j]);
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
  int a,b,c,d,l,r;
  cin >> a >> b >> c >> d;
  l=a+b;
  r=c+d;
  if(l>r){
    cout << "Left" << endl;
  }else if(l==r){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
}

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

int main(){

	char ch;
	int count[26] = {0};

	while (cin >> ch){
		if (isupper(ch)){
			ch = tolower(ch);
		}
			count[ch - 'a']++;

	}

	for (int i = 0; i < 26; i++){
		cout << (char)(i + 'a') << " : " << count[i] << endl;
	}

	return 0;

}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<int(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}

const int N=5005,mod=1e9+7;
int f[N][N],pa[N],mark[N],sz[N],s[N];
int n,c,p,con,ans;

int power(int x,int p){
	int res=1;
	for(;p;p>>=1,x=(ll)x*x%mod)
		if(p&1) res=(ll)res*x%mod;
	return res;
}
int mul(int x,int y){
	return (ll)x*y%mod;
}
void add(int &x,int y){
	x=(x+y>=mod?x+y-mod:x+y);
}
int gp(int x){
	return pa[x]==x?x:pa[x]=gp(pa[x]);
}

int main(){
	read(n);
	rep(i,1,n){
		pa[i]=i;
		sz[i]=1;
	}
	rep(i,1,n){
		read(p);
		if(p==-1) continue;
		if(gp(i)==gp(p)){
			mark[gp(i)]=1;
		}
		else{
			sz[gp(i)]+=sz[gp(p)];
			mark[gp(i)]|=mark[gp(p)];
			pa[gp(p)]=gp(i);
		}
	}
	rep(i,1,n){
		if(pa[i]!=i) continue;
		if(!mark[i]) s[++c]=sz[i];
		con++;
	}
	ans=mul(con-c,power(n-1,c));
	f[0][0]=1;
	rep(i,1,c){
		rep(j,0,i-1){
			add(f[i][j],f[i-1][j]);
			add(f[i][j+1],mul(f[i-1][j],s[i]));
		}
	}
	rep(i,1,c){
		int res=s[i]-1;
		res=mul(res,power(n-1,c-1));
		add(ans,res);
	}
	int coef=1;
	rep(i,2,c){
		int res=f[c][i];
		res=mul(res,power(n-1,c-i));
		res=mul(res,coef);
		add(ans,res);
		coef=mul(coef,i);
	}
	ans=(mul(n,power(n-1,c))+mod-ans)%mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 70464
N,W=map(int, raw_input().split())
A=[ map(int, raw_input().split())  for i in range(N) ] 

dp= [ None for i in range(W+1) ]
dp[0]=0

for w,v in A:
	for i in range(W,-1,-1):
		if dp[i] is not None:
			if 0<=i+w<=W:
				dp[i+w]=max( dp[i+w],  dp[i]+v )
print max(dp)

Measured memory_bytes: 41372
import scala.collection.mutable

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, m = sc.nextInt

  val fs = mutable.Set.empty[Int]
  val es = mutable.Set.empty[Int]

  (1 to m).foreach { _ =>
    val ai, bi = sc.nextInt
    if (ai == 1) fs.add(bi)
    if (bi == n) es.add(ai)
  }
  println(if ((fs & es).nonEmpty) "POSSIBLE" else "IMPOSSIBLE")
}

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

int main() {
  int n; string s;
  cin >> n >> s;
  bool answer = true;
  if (n % 2 == 1) answer = false;
  else {
    rep(i, n/2) {
      if(s[i] != s[n/2+i]) answer = false;
    }
  }
  if (answer) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define forsaken
#ifdef forsaken
  #define dbg(args...) do {cout << #args << " : "; err(args);} while (0)
#else
  #define dbg(...)
#endif
void err() {std::cout << std::endl;}
template<typename T, typename...Args>
void err(T a, Args...args){std::cout << a << ' '; err(args...);}
#define IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const int inf=0x3f3f3f3f;
const int max_n=100005;
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
	inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
int H,W,h,w;
bool vis[25][25];
int main()
{
    scanf("%d%d%d%d",&H,&W,&h,&w);
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=W;j++)vis[i][j]=true;
    }
    for(int j=1;j<=w;j++)
    {
        for(int i=1;i<=H;i++)vis[i][j]=true;
    }
    int ans=0;
    for(int i=1;i<=H;i++)
    {
        for(int j=1;j<=W;j++)if(!vis[i][j])ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165
int main(){
  int A, B, H, M;
  long double At, Bt, rad;
  cin >> A >> B >> H >> M;
  At = 30*H+(long double)M/(long double)2;//360*H/12 + 360/12*M/60
  Bt = 6*M;//360*M/60
  rad = (At-Bt)*PI/(long double)180;
  cout << setprecision(20) << sqrtl(A*A+B*B-2*A*B*cosl(rad));
}

Measured memory_bytes: 4160
#![allow(unused_imports)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::iter::once;
#[cfg(debug_assertions)]
include! {"./debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

macro_rules! read {
    ([$t:ident] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ([$t:ident]) =>
        (rl().split_whitespace().map(|w| read_type!(w, $t)).collect::<Vec<_>>());
    (_, [$t:ident] ; $n:expr) =>
        ((0..$n).map(|_| read!(_, [$t])).collect::<Vec<_>>());
    (_, [$t:ident]) =>
        (rl().split_whitespace().skip(1).map(|w| read_type!(w, $t)).collect::<Vec<_>>());
    ($($t:ident),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ($t:ident) => (read_type!(rl(), $t));
    ($($t:ident),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(read_type!(w.next().unwrap(), $t)),*)
    }};
}

macro_rules! read_type {
    ($s:expr, chars) => {
        $s.chars().collect::<Vec<char>>()
    };
    ($s:expr, usize1) => {
        read_type!($s, usize) - 1
    };
    ($s:expr, $t:ty) => {
        $s.parse::<$t>().unwrap()
    };
}

fn rl() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

////////////////////////////////////////////////////////////////////////////////

fn main() {
    let (n, k) = read!(usize, usize);

    let ans = if k == 1 { 0 } else { n - k };

    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char x = sc.next().charAt(0);
		char y = sc.next().charAt(0);
		System.out.println((x < y)? "<" : (x > y)? ">" : "=");
	}
}

Measured memory_bytes: 21844
/**
*   Bismillahir Rahmanir Rahim.
*   Imtiaz_rafi
*   PCIU, CHITTAGONG
**/
#include<bits/stdc++.h>
using namespace std;
#define speed ios::sync_with_stdio(0);cin.tie(0);
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
#define rep(i,a) for(ll i=0;i<a;i++)
#define rep1(i,begin,end) for(ll i=begin;i<=end;i++)
#define all(v)   v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define pi acos(-1)
// bitshift (1LL<<(3)) *2^3
typedef long long int ll;
typedef vector<ll>vi;
typedef map<ll,ll>m;
typedef map<char,ll>mc;
typedef set<ll>st;
typedef set<char>sc;
const ll mx = 1e5+123;
void printString(ll n)
{
    char str[26]; // To store result (Excel column name)
    int i = 0; // To store current index in str which is result

    while (n > 0) {
        // Find remainder
        int rem = n % 26;

        // If remainder is 0, then a 'Z' must be there in output
        if (rem == 0) {
            str[i++] = 'z';
            n = (n / 26) - 1;
        }
        else // If remainder is non-zero
        {
            str[i++] = (rem - 1) + 'a';
            n = n / 26;
        }
    }
    str[i] = '\0';

    // Reverse the string and print result
    reverse(str, str + strlen(str));
    cout << str << endl;

    return;
}
int main()
{
    speed;
    ll t,i,j,a,b,x,y,e=0,ans=0,sum=0;
    cin>>a;
    printString(a);
}



Measured memory_bytes: 3624
N=list(map(int,list("0"+input())))

ans = 0
while N:
    n = N.pop()
    if n>=10:
        N[-1] += 1
        n -= 10
    if n>=6:
        ans += 10-n
        N[-1] += 1
    elif n==5:
        if N[-1] >= 5:
            N[-1] += 1
            ans += 10-n
        else:
            ans += n
    else:
        ans += n
print(ans)

Measured memory_bytes: 20580
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>A>>B>>K;
    cout<<max(0LL, A - K)<<' ';
    K -= A;
    cout<<(K >= 0 ? max(0LL, B - K) : B)<<endl;
}

Measured memory_bytes: 256
#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 main(){
    int n;
    cin >> n;
    vector<int> x(n+1);
    rep(i,n+1) cin >> x[i];
    sort(x.begin(), x.end());
    int ans = x[1]-x[0];
    rep(i,n) ans = __gcd(ans, x[i+1]-x[i]);
    cout << ans << endl;
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define range(a,b)		substr(a,b-a+1)
#define w(x)            int x; cin>>x; while(x--)
#define trace(x) 		cerr<<#x<<": "<<x<<" "<<endl;
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
	FIO;
	int n; cin >> n;

	int ans = 0;

	for (int i = 1; i <= n; ++i)
		ans += (n - i + 1) * i;

	for (int i = 0; i < n - 1; ++i)
	{
		int u, v; cin >> u >> v;

		int r = max(u, v);
		int l = min(u, v);

		ans -= l * (n - r + 1);
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 3620
#include<cmath>
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
ll read()
{
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
const double eps=1e-13;
struct Point{double x,y;}p[105],p0;
Point operator -(Point a,Point b){return (Point){a.x-b.x,a.y-b.y};}
double cross(Point a,Point b){return a.x*b.y-a.y*b.x;}
double dot(Point a,Point b){return a.x*b.x+a.y*b.y;}
void read(Point &a){a.x=read(),a.y=read();}
int n;
int contain(Point p0)
{
	bool x=0;
	for(int i=0;i<n;i++)
	{
		Point a=p[i]-p0,b=p[(i+1)%n]-p0;
		if(fabs(cross(a,b))<eps&&dot(a,b)<eps)return 1;
		if(a.y>b.y)swap(a,b);
		if(a.y<eps&&b.y>eps&&cross(a,b)>eps)x^=1;
	}
	return x?2:0;
}
int main()
{
	n=read();
	for(int i=0;i<n;i++)read(p[i]);
	int q=read();while(q--)
	{
		read(p0);
		printf("%d\n",contain(p0));
	}
	return 0;
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include<vector>
using namespace std;
int main(){
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(c-e>=0&c+e<=a&d-e>=0&d+e<=b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3116
N=int(input())

A=[[0]*3 for i in range(N+1)]
for i in range(N):
  a=list(map(int,input().split()))
  A[i]=a

#ステップ1
dp=[[-float('inf')] * 3 for i in range(N+1)]
#N+1行作っておくことでループを回すときにN日目だけ分けて考える必要がなくなる。

#ステップ2
dp[0]=A[0] #初日にAを実行する日の幸福度は確定している。以下同様。

#ステップ3
for i in range(N):
  for j in range(3): #i+1日目に行うアクティビティ
    for k in range(3): #i+2日目に行うアクティビティ
      if j != k: #2日連続同じアクティビティは禁止
        if dp[i+1][k] < dp[i][j] + A[i+1][k]:
          dp[i+1][k] = dp[i][j] + A[i+1][k]
        
#ステップ4
ans=max(dp[N-1])
print(ans)

Measured memory_bytes: 112584
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
using namespace std;
using ll=long long;
#ifdef ONLINE_JUDGE
#define D(...)
#else
#define D(...)cerr<<__LINE__<<":"<<"["<<#__VA_ARGS__<<"]->",P(__VA_ARGS__)
#endif
void P(){cerr<<endl;} 
template<typename H,typename...T>void P(H h,T...t){cerr<<h<<" ";P(t...);}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n,k;cin>>n>>k;
    vector<int>v(n);
    for(auto &x:v)
        cin>>x;
    cout<<ceil(double(n-1)/(k-1))<<endl;



}

Measured memory_bytes: 3836
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
    double r;
    cin >> r;

    double S = r * r * M_PI;
    double shu = 2 * r * M_PI;

    printf("%.5f %.5f", S, shu);
}

Measured memory_bytes: 1240
w, h , n = map(int, input().split())
x1=0
y1=0
x2=w
y2=h
for i in range(0,n):
	x , y, a = map(int , input().split())
	if a==1:
		x1 = max(x1,x)
	elif a==2:
		x2=min(x2, x)
	elif a==3:
		y1=max(y1, y)
	else:
		y2=min(y2, y)
ar=(y2-y1)*(x2-x1)
if y2-y1<=0 or x2-x1<=0:
	print(0)
else:
	print(ar)

Measured memory_bytes: 61876
s = input()

ans = True

for i in range(len(s)) :
    if i % 2 == 0 :
        if s[i] == 'L' :
            ans = False
    else :
        if s[i] == 'R' :
            ans = False

if ans :
    print('Yes')
else :
    print('No')


Measured memory_bytes: 3068
/*
░░░░░░░░░░░░░░░░▄▄█▀▀██▄▄░░░░░░░
░░░░░░░░░░░░░▄█▀▀░░░░░░░▀█░░░░░░
░░░░░░░░░░░▄▀░░░░░░░░░░░░░█░░░░░
░░░░░░░░░▄█░░░░░░░░░░░░░░░█░░░░░
░░░░░░░██▀░░░░░░░▄▄▄░░▄░█▄█▄░░░░
░░░░░▄▀░░░░░░░░░░████░█▄██░▀▄░░░
░░░░█▀░░░░░░░░▄▄██▀░░█████░██░░░
░░░█▀░░░░░░░░░▀█░▀█▀█▀▀▄██▄█▀░░░
░░░██░░░░░░░░░░█░░█░█░░▀▀▄█▀░░░░
░░░░█░░░░░█░░░▀█░░░░▄░░░░░▄█░░░░
░░░░▀█░░░░███▄░█░░░░░░▄▄▄▄█▀█▄░░
░░░░░▀██░░█▄▀▀██░░░░░░░░▄▄█░░▀▄░
░░░░░░▀▀█▄░▀▄▄░▄░░░░░░░███▀░░▄██
░░░░░░░░░▀▀▀███▀█▄░░░░░█▀░▀░░░▀█
░░░░░░░░░░░░▄▀░░░▀█▄░░░░░▄▄░░▄█▀
░░░▄▄▄▀▀▀▀▀█▀░░░░░█▄▀▄▄▄▄▄▄█▀▀░░
░▄█░░░▄██▀░░░░░░░░░█▄░░░░░░░░░░░
█▀▀░▄█░░░░░░░░░░░░░░▀▀█▄░░░░░░░░
█░░░█░░░░░░░░░░░░░░░░░░█▄░░░░░░░*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
#define mp make_pair
const ll mod = 1000000007;
const ll nmax=2525*1001;
#define int ll
int n, q;
vi g[200002];
int dp[200002], ans[200002], cur;

int dfs(int nod, int p){
	cur+=dp[nod];
	ans[nod]=cur;
	for(int i: g[nod]){
		if(i!=p) dfs(i, nod);
	}
	cur-=dp[nod];
}

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
	cin>>n>>q;
	for(int i=1; i<=n-1; i++){
		int a, b;
		cin>>a>>b;
		g[a].pb(b);
		g[b].pb(a);
	}
	while(q--){
		int p, x;
		cin>>p>>x;
		dp[p]+=x;
	}
	dfs(1, 0);
	for(int i=1; i<=n; i++) cout<<ans[i]<<" ";
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int P, Q, R;;
    cin >> P >> Q >> R;

    int ans;
    ans = min(P + Q, min(Q + R, R + P));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> ipair;
typedef pair<ll, ll> lpair;
typedef tuple<int, int, int> ituple;

// const int INF = INT_MAX;
// const ll INF = LLONG_MAX;
// const int MOD = ((int)1e9 + 7);
// const ld EPS = (1e-10);
#define PI acosl(-1)
#define MAX_N (100000 + 2)

void exec(){
  int d, t, s;
  cin >> d >> t >> s;
  bool isOK = t * s >= d;
  cout << (isOK ? "Yes" : "No") << endl;

}

void solve(){
  int t = 1;
  // scanf("%d", &t);
  for (int i = 0; i < t; i++){
    exec();
  }
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 3592