akhauriyash/Code-Regression huggingface dataset:
/*
"IOI 2018" Japan, Tokyo.
*/
#include <bits/stdc++.h>

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define pp pop_back()
#define ll long long
#define ld long double
#define ok puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

inline ll min(ll a, ll b) {
    return (a > b) ? b : a;
}

inline ll max(ll a, ll b) {
    return (a > b) ? a : b;
}

const int N = 1e5 + 7;
const int inf = 1e9 + 7;
const ll linf = 1e18 + 9;

int a[N];

main() {
    int n; cin >> n;
    for (int i = 1; i <= n; i++) {
        scanf ("%d", a + i);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (a[i] == i) {
            if (i == n) {
                swap(a[i], a[i - 1]);
                ans++;
            } else {
                swap(a[i], a[i + 1]);
                ans++;
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 640
while True:
    a,b=input().split()
    if b=='X':
        break
    a=list(a)
    if ('_' in a) and (b=='U' or b=='L'):
        c=0
        for i in range(len(a)):
            if i==0 and b=='U':
                a[i]=a[i].upper()
            elif a[i]=='_':
                c+=1
            elif c==1:
                a[i]=a[i].upper()
                c=0
        a=[i for i in a if i!='_']
    elif b=='U':
        a[0]=a[0].upper()
    elif b=='L':
        a[0]=a[0].lower()
    else:
        s=0
        for i in range(len(a)):
            if i==0:
                a[0]=a[0].lower()
                s+=1
            elif a[s].isupper():
                a[s]=a[s].lower()
                a.insert(s,'_')
                s+=2
            else:
                s+=1
    for i in range(len(a)):
        if i==len(a)-1:
            print(a[i])
        else:
            print(a[i],end='')


Measured memory_bytes: 5588
# import sys
# read = sys.stdin.buffer.read
# readline = sys.stdin.buffer.readline
# readlines = sys.stdin.buffer.readlines

# def myinput():
#     return map(int,readline().split())

# abcd = list(map(int,(list(input()))))
# print(abcd)

abcd = input()

for i in range(2**3):
    r = int(abcd[0])
    ans = abcd[0]
    for j in range(3):
        # op="+"の場合
        if i & (2**j):
            ans = ans + "+" + abcd[j+1]
            r += int(abcd[j+1])
        # op="-"の場合
        else: 
            ans = ans + "-" + abcd[j+1]
            r -= int(abcd[j+1])
    if r==7:
        output = ans + "=7"
# print(r)
# print(ans)
print(output)

Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <cstring>
const int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{1,1},{-1,-1},{1,-1},{-1,1}};
using namespace std;

int main()
{
    int n,m;
    char ch[55][55];
    int b[55][55];
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        memset(b,0,sizeof(b));
        for (int i=0;i<n;i++) scanf("%s",ch[i]);
        for (int i=0;i<n;i++)
            for (int j=0;j<m;j++)
            if (ch[i][j]=='#') b[i][j]=-1;
        for (int i=0;i<n;i++)
            for (int j=0;j<m;j++)
            {
                if (b[i][j]==-1)
                  {
                      for (int k=0;k<8;k++)
                        if (i+dir[k][0]>=0&&i+dir[k][0]<n&&j+dir[k][1]>=0&&j+dir[k][1]<m)
                        if (b[i+dir[k][0]][j+dir[k][1]]!=-1) b[i+dir[k][0]][j+dir[k][1]]++;
                  }
            }
        for (int i=0;i<n;i++)
            {for (int j=0;j<m;j++)
                if (b[i][j]==-1) printf("#");
                else printf("%d",b[i][j]);
                printf("\n");
            }
    }
    return 0;
}


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

int solve(int N) {
    vector<vector<int>> sp(N + 1);
    int people;
    int have;
    for (int i = 0; i < N; i++) {
        cin >> people;
        for (int j = 0; j < people; j++) {
            cin >> have;
            sp[i + 1].push_back(have);
        }
    }
    int L;
    cin >> L;
    vector<int> lost(L);
    for (int i = 0; i < L; i++) {
        cin >> lost[i];
    }
    int cnt = 0;
    int ret;
    for (int i = 0; i < sp.size(); i++) {
        if (sp[i].size() >= L) {
            int check = 0;
            for (int j = 0; j < lost.size(); j++) {
                for (int k = 0; k < sp[i].size(); k++) {
                    if (sp[i][k] == lost[j]) {
                        check++;
                    }
                }
            }
            if (check == L) {
                cnt++;
                ret = i;
            }
        }
    }

    if (cnt == 1)
        return ret;
    else
        return -1;
}

int main() {
    int N;
    vector<int> ans;
    while (cin >> N) {
        if (!N) break;
        ans.push_back(solve(N));
    }
    for (int i : ans) cout << i << endl;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W));
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      cin >> a.at(i).at(j);
    }
  }
  
  vector<bool> row(H, false);
  vector<bool> col(W, false);
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (a.at(i).at(j) == '#') {
        row.at(i) = true;
        col.at(j) = true;
      }
    }
  }
  
  for (int i = 0; i < H; i++) {
    if (row.at(i)) {
      for (int j = 0; j < W; j++) {
        if (col.at(j)) {
          cout << a.at(i).at(j);
        }
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int>a(N+1),b(N+1),c(N+1);
  for(int i=1;i<=N;i++)cin>>a[i]>>b[i]>>c[i];
  vector<int>dp(3);
  dp[0]=a[1];
  dp[1]=b[1];
  dp[2]=c[1];
  for(int i=2;i<=N;i++){
    vector<int>dp2(3);
    dp2[0]=max(dp[1],dp[2])+a[i];
    dp2[1]=max(dp[2],dp[0])+b[i];
    dp2[2]=max(dp[0],dp[1])+c[i];
    swap(dp,dp2);
  }
  cout<<max({dp[0],dp[1],dp[2]})<<endl;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner scan = new Scanner(System.in);
		int W = scan.nextInt();
		int H = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		int r = scan.nextInt();
		
		if (((x+r) <= W) && ((y+r) <= H) && ((x-r) >= 0) && ((y-r) >= 0)) System.out.println("Yes");
		else System.out.println("No");
		
	}

}

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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf (1 << 21)
#define mod 1000000007

int main() {
    double a, b, x; cin >> a >> b >> x;
    double bx = x / pow(a, 2);
    double y = b - bx;
    double rad,theta;
    if (bx - y >= 0) {
        rad = atan(2 * y / a);
    }
    else {
        double xa = (2 * x) / (a * b);
        if (xa > 0) {
            rad = atan(b / xa);
        }
        else {
            rad = pi / 2;
        }
    }
    theta = (rad * (double)180) / pi;
    cout << fixed << setprecision(10);
    cout << theta << endl;
    return 0;
}


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

template <typename T> using vector2d = vector<vector<T>>;

// clang-format off
template <typename T> void sort(vector<T> &v) { sort(all(v)); }
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  cout << in() / 3 << endl;
}


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

using namespace std;

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

  vector<bool> dp(n);
  vector<int> sz(n, 1);
  dp[0] = true;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    dp[y] = (dp[x] ? true : dp[y]);
    sz[y]++;
    if (--sz[x] == 0) dp[x] = false;
  }

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

  return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	int n, m;
	cin >> n >> m;

	vector<int> h(n);
	vector<bool> isGood(n);
	vector<int> a(m);
	vector<int> b(m);

	for(int i = 0; i < n; ++i)
	{
		cin >> h[i];
		isGood[i] = true;
	}
	for(int i = 0; i < m; ++i)
	{
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;

		isGood[a[i]] = isGood[a[i]] & ( h[b[i]] < h[a[i]] );
		isGood[b[i]] = isGood[b[i]] & ( h[a[i]] < h[b[i]] );
	}

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

	cout << ans << endl;

}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 4520
def f(n,x):
    if n==0:return 0 if x<=0 else 1
    elif x<=1+a[n-1]:
        return f(n-1,x-1)
    else:
        return p[n-1]+1+f(n-1,x-2-a[n-1])


n,x=map(int,input().split())
a,p=[1],[1]

for i in range(n):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

print(f(n,x))


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  ui N, T; cin >> N >> T;
  pair<uc, ui> res{0, std::numeric_limits<ui>::max()};
  for(ui tmp = 0; tmp < N; ++tmp)
  {
    ui c, t; cin >> c >> t;
    if(t <= T)
    {
      ++res.first;
      chmin(res.second, c);
    }
  }

  cout << (res.first ? std::to_string(res.second) : "TLE" ) << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x, n;
  cin >> x >> n;
  vector<int>q(102); //0で初期化される
  for (int i=0; i<n; i++){
    int p;
    cin >> p;
    q[p] = 1;
  }
  int mini = 10000000;
  int ans = 0;
  for (int i=0; i<102; i++){
    if (q[i]==1) continue;
    else{
      if (abs(x-i)<mini){
        mini = min(abs(x-i), mini);
        ans = i;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n, k;
vector<int> v;
int dp[100005];


void solve()
{
	for (int i = 1; i <= k; ++i)
	{
		if(dp[i] >= 0)
			continue;

		int res;
		for (int j = 0; j < n; ++j)
		{
			int tam = (i - v[j]);
			if(tam < 0)
				continue;
			res = dp[tam];
			if(res == 1)
			{
				dp[i] = 2;
			}
			else if(res == 2)
			{
				dp[i] = 1;
				break;
			}
		}

	}

}


int main()
{

	cin >> n >> k;


 	memset(dp, -1, sizeof(dp));
 
 	int num1, menor = 1000002;
 	for (int i = 0; i < n; ++i)
 	{
 		cin >> num1;
 		v.push_back(num1);
 		dp[num1] = 1;
 		menor = min(menor, num1);
 	}

 	for (int i = 0; i < menor; ++i)
 	{
 		dp[i] = 2;
 	}

 	solve();

 	if(dp[k] == 1 || dp[k] == 3)
 		cout << "First\n";
 	else
 		cout << "Second\n";


 






















    return 0;
}

Measured memory_bytes: 3928
n=int(input())
A=[int(i) for i in input().split()]
m=int(input())
B=[int(i) for i in input().split()]

for i in range(len(B)):
    C=[[0 for j in range(B[i]+1)]for k in range(len(A)+1)]
    for j in range(1,len(A)+1):
        for k in range(1,B[i]+1):
            if A[j-1]<=k:
                C[j][k]=max(C[j-1][k-A[j-1]]+A[j-1],C[j-1][k])
            else:
                C[j][k]=C[j-1][k]

    if C[len(A)][B[i]]==B[i]:
        print("yes")
    else:
        print("no")

        


Measured memory_bytes: 6956
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>

#define rep0(i, n) for (i = 0; i < n; i++)
#define rep(s, i, n) for (i = s; i < n; i++)
using namespace std;

int main()
{
    int a;
    cin >> a;
    cout << a+a*a+a*a*a << endl;
    return 0;
}

Measured memory_bytes: 3612
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}
int ll_gcd(ll a, ll b);
int ll_gcd(ll a, ll b) {
	if (!b)return a;
	return ll_gcd(b, a % b);
}
int ll_lcm(ll a, ll b);
int ll_lcm(ll a, ll b) {
	return (a * b) / ll_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
//ll _pfact(ll a);
//static ll pf[100000000];
//static ll pc;
//
//ll _pfact(ll a) {
//	long i, r;
//	if (a % 2 == 0) {
//		pf[pc] = 2; pc++;
//		return(_pfact(a / 2));
//	}
//	r = sqrt(a);
//	for (i = 3; i <= r; i += 2) {
//		if (a % i == 0) {
//			pf[pc] = i; pc++;
//			return(_pfact(a / i));
//		}
//	}
//	if (a != 1) {
//		pf[pc] = a; pc++;
//	}
//	return 0;
//
//}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}
// 立っている ビットの数
int bitcount(unsigned int uc);
int bitcount(unsigned int uc)
{
	int bit;

	for (bit = 0; 0 != uc; uc = (unsigned int)(uc >> 1))
		if (0 != (uc & 1))++bit;

	return bit;
}//bitco

#define _rnd(a,b)    ((a+b-1)/b) //　A/Bの余りを繰り上げる

#pragma endregion

// ABC081 A- Placing Marbles
int main(void) {
	char c1, c2, c3;
	int  ans=700;
	
	scanf("%c%c%c",&c1,&c2,&c3);
	
	if (c1 == 'o') ans+=100;
	if (c2 == 'o') ans+=100;
	if (c3 == 'o') ans+=100;

	printf("%d\n",ans);

	return 0;
}

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

int main() {
    int L, R;
    cin >> L >> R;
    int ans = 2018;
    if(R - L >= 2018) ans = 0;
    else {
        rep(l, L, R) rep(r, l + 1, R + 1) {
            int m = l % 2019, n = r % 2019;
            ans = min(ans, m * n % 2019);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		int K = in.nextInt();
		int sum = 0;
		Integer a[] = new Integer[N];
		Integer b[] = new Integer[K];
		
		for(int i = 0;i < N;i++) {
			a[i] = in.nextInt();
		}
		
		Arrays.sort(a,Comparator.naturalOrder());
		
		for(int i = 0;i < K;i++) {
			b[i] = a[i];
		}
		
		for(int i = 0;i < K;i++) {
			sum += b[i];
		}
		
		System.out.println(sum);
	}
}

Measured memory_bytes: 38876
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) tsort(v); reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

lint dx[8] = { 0,1,1,1,0,-1,-1,-1 },
     dy[8] = { 1,1,0,-1,-1,-1,0,1 };

template<class T>bool maxi(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool mini(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    lint x,a,b;
    cin>>x>>a>>b;
    coc(abs(a-x)<abs(b-x), "A", "B");
}

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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
#define MP make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;
typedef pair < ll , ll > pll;

const double PI = acos(-1);
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;
const int INF = 1e9;
	

ll addMod(ll a, ll b){
	if(a + b >= MOD) return a + b - MOD;
	return a + b;
}

ll mulMod(ll a, ll b){
	return (a*b)%MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp,tmp);
	if(b%2 == 1) tmp = mulMod(tmp,a);
	return tmp;
}

ll GCD(ll a, ll b){
	if(a > b) return GCD(b,a);
	if(a == 0) return b;
	return GCD(b%a,a);
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

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

string ans[] = {"Sunny", "Cloudy", "Rainy"};

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string str;
	cin >> str;
	FOR(i,3){
		if(str == ans[i]){
			cout << ans[(i+1)%3] << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#define rep1(i,s,e,c) for(int i=s;i<e;i=i+c)
#define rep2(i,s,e,c) for(int i=s;i<=e;i=i+c)
#define rep3(i,e,s,c) for(int i=e;i>=s;i=i-c)
using namespace std;
typedef long long ll;
const int MAX=1e5+5;
const int MOD=1e9+7;
int main()
{    
    int k,x;
    cin>>k>>x;
    for(int i=x-k+1;i<=x+k-1;i++){
    	if(i!=x-k+1) cout<<" ";
    	cout<<i;
	}
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
char map[101][101];
int w,h,cnt;
char hoge;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
void dfs(int,int);
int main(){
  while(1){
    cnt=0;
    cin >> h >> w;
    if(w == 0 && h == 0)break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> map[i][j];
      }
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(map[i][j]!='.'){
	  cnt++;
	  hoge=map[i][j];
	  dfs(j,i);
	}
      }
    }
    printf("%d\n",cnt);
  }
}

void dfs(int x,int y){
  map[y][x]='.';
  for(int i=0;i<4;i++){
    int nx=x+dx[i];
    int ny=y+dy[i];
    if(nx >= 0&& nx < w && ny >= 0 && ny < h && map[ny][nx]==hoge){
	dfs(nx,ny);
      }
  }
}

Measured memory_bytes: 1460
use proconio::input;

fn main() {
    input! {
        n: usize,
    }

    let mut dp = vec![std::usize::MAX; n + 1];

    dp[0] = 0;

    for n in 1..=n {
        dp[n] = dp[n-1] + 1;
        let mut num6 = 6;
        while num6 <= n {
            dp[n] = std::cmp::min(dp[n], dp[n-num6] + 1);
            num6 *= 6;
        }
        let mut num9 = 9;
        while num9 <= n {
            dp[n] = std::cmp::min(dp[n], dp[n-num9] + 1);
            num9 *= 9;
        }
    }

    let ans = dp[n];

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

Measured memory_bytes: 2732
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a; cin >> a;
    cout << a + a * a + a * a * a << endl;

    return 0;
}


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


int main(){
  int n;
  cin >> n;
  long long ans=0;
  for(int i=0;i<n;++i){
    long long l,r;
    cin >> l >> r;
    ans+=(r-l);
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//ここまで毎回include
//以下プログラム

using namespace std;

int main() {
	int x, y;
	cin >> x >> y;
	int result = INT_MAX;
	if (x <= y) {
		result = min(result, 0 + y - x + 0);
	}
	if (-x <= y) {
		result = min(result, 1 + y - -x  + 0);
	}
	if (x <= -y) {
		result = min(result, 0 + -y - x + 1);
	}
	if (-x <= -y) {
		result = min(result, 1 + -y - -x + 1);
	}
	cout << result << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define N_MAX 10000
#define TRUE 1
#define FALSE 0

int isPrime(int);

int main(){
  int i, n, count = 0, x[N_MAX];

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &x[i]);
  }
  
  for(i = 0; i < n; i++){
    count += isPrime(x[i]);
  }

  printf("%d\n", count);

  return 0;
}


int isPrime(int x){
  int i;
  if(x == 2) return TRUE;
  if(x < 2 || x % 2 == 0) return FALSE;
  for(i = 3; i <= sqrt(x); i += 2){
    if(x % i == 0) return FALSE;
  }
  return TRUE;
}



Measured memory_bytes: 2084
n,x,y=map(int,input().split())
ans=[0]*(n-1)
for i in range(1,n):
    for j in range(i+1,n+1):
        num1=j-i
        num2=abs(i-x)+abs(j-y)+1
        ans[min(num1,num2)-1]+=1
for i in ans:
    print(i)


Measured memory_bytes: 9260
#include<iostream>
using namespace std;
int main(){
    while(true){
       int i,j,k,n,x,tem=0;
       cin >> n >> x;
       if(n == 0 && x == 0)break;
       for(i=1;i<=n-2;i++){
           for(j=i+1;j<=n-1;j++){
               for(k=j+1;k<=n;k++){
                   if((i+j+k == x) && (i!=j || j!=k ||i!=k))tem = tem+1;
               }
           }
       }
       cout << tem << endl;
    }
}


Measured memory_bytes: 3080
n, y = map(int,input().split())
count = 0

def check():
    for man in range(n+1):
        for gosen in range(n-man+1):
                if y == 10000*man + 5000*gosen + 1000*(n-man-gosen):
                    return man, gosen , n-man-gosen
    return -1, -1, -1

i, j, k = check()
print(i, j, k)

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF INT32_MAX / 2
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    int n, m;
    cin >> n >> m;
    int a, b;
    priority_queue<pair<int, int>, vector<pair<int, int>>,
                   greater<pair<int, int>>>
        q;
    while (n--) {
        cin >> a >> b;
        q.push(make_pair(a, b));
    }
    int res = 0;
    priority_queue<int> candicate;
    for (int i = m; i >= 0; i--) {
        while (1) {
            if (q.empty())
                break;
            if (q.top().first + i <= m) {
                auto top = q.top();
                candicate.push(top.second);
                q.pop();
            }
            else
                break;
        }
        if (candicate.empty())
            continue;
        res += candicate.top();
        candicate.pop();
    }
    cout << res << endl;
}

Measured memory_bytes: 4720
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    X = int(input())
    a = 100
    counter = 0
    while a < X:
        a = (a * 1.01)//1
        counter += 1
    print(counter)

if __name__ == "__main__":
    main()



Measured memory_bytes: 9224
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MASK30 = (1 << 30) - 1
MASK31 = (1 << 31) - 1
MASK61 = (1 << 61) - 1

@njit((i8, ), cache=True)
def rh_modulo(x):
    xu, xd = x >> 61, x & MASK61
    x = xu + xd
    if x >= MASK61:
        x -= MASK61
    return x


@njit((i8, i8), cache=True)
def rh_multiply(a, b):
    au, ad = a >> 31, a & MASK31
    bu, bd = b >> 31, b & MASK31
    x = ad * bu + au * bd
    xu, xd = x >> 30, x & MASK30
    return rh_modulo(au * bu * 2 + xu + (xd << 31) + ad * bd)


@njit((i8, i8), cache=True)
def rh_pows(base, max_len):
    pows = np.empty(max_len, np.int64)
    pows[0] = 1
    for n in range(1, max_len):
        pows[n] = rh_multiply(pows[n - 1], base)
    return pows


@njit((i8[:], i8, i8[:]), cache=True)
def compute_rh(pows, base, S):
    N = len(S)
    RH = np.empty(N, np.int64)
    RH[0] = S[0] + 10
    for n in range(1, N):
        x = rh_multiply(RH[n - 1], base) + S[n] + 10
        if x >= MASK61:
            x -= MASK61
        RH[n] = x
    return RH


@njit((i8[:], i8, i8[:], i8, i8), cache=True)
def rh_substr(pows, base, RH, l, r):
    h = RH[r]
    if l > 0:
        h -= rh_multiply(RH[l], pows[r - l])
    if h < 0:
        h += MASK61
    return h

@njit((i8[:], ), cache=True)
def main(S):
    S = S.copy()
    l_ind = np.where(S == -1)[0][:-1] + 1
    r_ind = np.where(S == -1)[0][1:]
    N = len(l_ind)
    # 逆順にしておく
    for i in range(N):
        S[l_ind[i]:r_ind[i]] = S[l_ind[i]:r_ind[i]][::-1]

    # rolling hashの計算
    max_len = len(S) + 10
    base = np.random.randint(0, 1 << 31)
    pows = rh_pows(base, max_len)
    RH = np.zeros_like(S)
    for i in range(N):
        RH[l_ind[i]:r_ind[i]] = compute_rh(pows, base, S[l_ind[i]:r_ind[i]])

    # 後ろ（自身も含む）に置ける文字集合の計算
    sets = np.zeros_like(S)
    for i in range(N):
        for j in range(r_ind[i] - 1, l_ind[i] - 1, -1):
            sets[j] = sets[j + 1] | 1 << S[j]

    # 作れる組 (prefix, 右からの1文字)をすべて計算する
    ptr = 0
    nums = np.empty(len(S) * 26 + 10, np.int64)
    for i in range(N):
        for j in range(l_ind[i], r_ind[i]):
            for k in range(26):
                if sets[j] & 1 << k:
                    h = rh_multiply(RH[j - 1], base) + k
                    nums[ptr] = h
                    ptr += 1
    nums = nums[:ptr]
    nums.sort()
    # 各文字列とマッチングする対象を数える
    ans = 0
    for i in range(N):
        h = rh_multiply(RH[r_ind[i] - 2], base) + S[r_ind[i] - 1]
        cnt = np.searchsorted(nums, h, 'right')
        cnt -= np.searchsorted(nums, h, 'left')
        ans += cnt - 1  # 自分を除外
    print(ans)

N = int(readline())
S = np.array(list(read().rstrip()), np.int64)

S[S == ord('\n')] = -1
S[S > 0] -= ord('a')
S = np.insert(S, 0, -1)
S = np.append(S, -1)

main(S)

Measured memory_bytes: 346000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll max_N = 1e5 + 50;
ll N, M;
vector<ll> adj[max_N];
vector<ll> top_order;
bool vis[max_N];
ll DP[max_N];
ll inord[max_N];

void toposort_bfs()
{
    queue<ll> que;
    for (int i = 1; i <= N; ++i)
        if (!inord[i])
            que.push(i);
    while (!que.empty())
    {
        ll curr = que.front();
        que.pop();
        top_order.push_back(curr);
        for (auto &neigh: adj[curr])
        {
            --inord[neigh];
            if (!inord[neigh])
                que.push(neigh);
        }
    }
}

int main()
{
    cin >> N >> M;
    ll x, y;
    for (int i = 0; i < M; ++i)
    {
        cin >> x >> y;
        adj[x].push_back(y);
        ++inord[y];
    }
    toposort_bfs();
    ll res = 1;
    for (int i = N - 1; i >= 0; --i)
    {
        ll curr = top_order[i];
        DP[curr] = 0;
        for (ll &neigh : adj[curr])
        {
            DP[curr] = max(DP[curr], 1 + DP[neigh]);
        }
        res = max(res, DP[curr]);
    }
    cout << res << "\n";
    return 0;
}

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

const int INF = 1e+9+7;
const int N=10;
int main(){
    int H,W;
    cin >> H >> W;
    vector<vector<int>> dp(N,vector<int>(N));

    rep(i,N){
        rep(j,N){
            cin >> dp[i][j];
        }
    }

    

    rep(k,N){
        rep(i,N){
            rep(j,N){
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
            }
        }
    }

    int ans=0;
    int tmp;
    rep(i,H){
        rep(j,W){
            cin >> tmp;
            if(tmp!=-1){
                ans+=dp[tmp][1];
            }

        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N;
  cin>>N;
  map<string,ll> mp;
  for(ll i=0;i<N;i++){
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    mp[s]++;
  }
  ll ans=0;
  for(auto v:mp){
    ll tmp=v.second;
    ans+=(tmp*(tmp-1))/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define FASTIO() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N = 200005, M = 1000000007, BIG = 0x3f3f3f3f;

int ct = 0;
ll n;
ll a, b;

bool Read() {
  cin >> n;
  if (cin.eof())
    return 0;
  cin >> a >> b;

  return 1;
}

void Process() {
  ll q = n / (a + b);
  ll r = n % (a + b);
  ll ans = q * a;
  if (r > 0)
    ans += min(a, r);
  cout << ans << "\n";
}

int main() {
  FASTIO();

  while (Read())
    Process();

  return 0;
}

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

int main(){
  
  string s;
  cin >> s;
  
  if(s == "ooo"){
    cout << "1000" << endl;
  }
  
  else if( s == "xoo" || s == "oxo" || s == "oox" ) {
    cout << "900" << endl;
  }
  
  else if( s == "oxx" || s == "xox"|| s == "xxo" ){
    cout << "800" << endl;
  }
  
  else{
    cout << "700" << endl;
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static auto faster_iostream = []() { ios::sync_with_stdio(0); cin.tie(0); return 0; }();
typedef long long ll; typedef double db;
const int N = 2e5 + 5, M = 1e9 + 7;
struct edge {
  int u, v;
  ll w;
  bool operator < (const edge &b) const { return w < b.w; }
};

vector<edge> G[N], g;
int siz[N], maxx[N], sum, rt;
bool vis[N];
void getrt(int u, int f) {
  siz[u] = 1, maxx[u] = 0;
  for (auto &e : G[u]) {
    int v = e.v;
    if (v == f || vis[v]) continue;
    getrt(v, u);
    maxx[u] = max(maxx[u], siz[v]);
    siz[u] += siz[v];
  }
  maxx[u] = max(maxx[u], sum - siz[u]);
  if (maxx[u] < maxx[rt]) rt = u;
}
ll a[N], val, p;
void getdis(int u, int f, ll dep) {
  if (dep + a[u] < val) val = dep + a[u], p = u;
  for (auto &e : G[u]) {
    int v = e.v;
    if (vis[v] || v == f) continue;
    getdis(v, u, dep + e.w);
  }
}
void getedge(int u, int f, ll dep) {
  g.push_back({u, p, dep + a[u] + val});
  for (auto &e : G[u]) {
    int v = e.v;
    if (vis[v] || v == f) continue;
    getedge(v, u, dep + e.w);
  }
}
int n;
void dfz(int u) {
  vis[u] = 1;
  val = a[u], p = u;
  getdis(u, 0, 0);
  getedge(u, 0, 0);
  for (auto &e : G[u]) {
    int v = e.v;
    if (vis[v]) continue;
    sum = siz[v]; maxx[rt = 0] = n;
    getrt(v, u); dfz(rt);
  }
}
int par[N];
int fi(int x) {
  if (par[x] == x) return x;
  return par[x] = fi(par[x]);
}
int main() {
  int u, v, w;
  cin >> n;
  for (int i = 1; i <= n; i++) par[i] = i;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i < n; i++) {
    cin >> u >> v >> w;
    G[u].push_back({u, v, w});
    G[v].push_back({v, u, w});
  }
  maxx[rt] = sum = n;
  getrt(1, 0); dfz(rt);
  sort(g.begin(), g.end());
  ll ans = 0;
  for (auto &e : g) {
    int u = fi(e.u), v = fi(e.v);
    if (u != v) ans += e.w, par[u] = v;
  }
  cout << ans << endl;
}


Measured memory_bytes: 99680
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>

using namespace std;

void solv()
{
	char S[10]; scanf("%s", S);
	int ret = 0;
	if (0 == strcmp("SUN", S)){
		ret = 7;
	}
	else if (0 == strcmp("MON", S)){
		ret = 6;
	}
	else if(0 == strcmp("TUE", S)){
		ret = 5;
	}
	else if(0 == strcmp("WED", S)){
		ret = 4;
	}
	else if(0 == strcmp("THU", S)){
		ret = 3;
	}
	else if(0 == strcmp("FRI", S)){
		ret = 2;
	}
	else if (0 == strcmp("SAT", S)){
		ret = 1;
	}

	printf("%d", ret);

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

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

int main() {
 string s;
  cin>>s;
 int n=s.size();
  for(int i=0;i<(n-1)/2;i++){
    if(s[i]!=s[(n-3)/2-i]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  for(int i=(n+1)/2;i<n;i++){
    if(s[i]!=s[n-1-i]){
    cout<<"No"<<endl;
return 0;
    }
  }
 cout<<"Yes"<<endl;
return 0;
}


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

int asc(const void *a, const void *b) {
  return *(int *)b - *(int *)a;
}

int main() {
	int n, k, l[55];
	int ans = 0;
	cin >> n >> k;
	rep(i, n) cin >> l[i];
	qsort(l, n, sizeof(int), asc);
	rep(i, k) ans += l[i];
	cout << ans << endl;
}

Measured memory_bytes: 256
using System;
class program{
  static void Main(){
    string[] val = Console.ReadLine().Split(' ');
    int n = int.Parse(val[0]);
    int m = int.Parse(val[1]);
    long k = long.Parse(val[2]);
    string[] a = Console.ReadLine().Split(' ');
    long[] A = new long[n+1];
    A[0] = 0;
    for(int i=1;i<n+1;i++) A[i]=A[i-1]+long.Parse(a[i-1]);
    string[] b = Console.ReadLine().Split(' ');
    long[] B = new long[m+1];
    B[0] = 0;
    for(int i=1;i<m+1;i++) B[i]=B[i-1]+long.Parse(b[i-1]);
    int ans = 0;
    int j = m;
    for(int i=0;i<n+1 && A[i]<=k;i++){
      while(A[i]+B[j]>k){
        j--;
      }
      if(ans < i+j) ans = i+j;
    }
    Console.WriteLine(ans);
  }
}

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

typedef long long int lli;
typedef pair <int, int> ii;
typedef vector <int> vi;
typedef vector <ii> vii;

#define INF 1000000000
#define fastIO ios::sync_with_stdio(false);cout.tie(0);cin.tie(0);
#define endl '\n'
#define foreach(v,c) for(typeof((c).begin()) v=(c).begin();v!=(c).end();++v)
#define all(a) a.begin(),a.end()
#define in(a,b) ((b).find(a)!=(b).end())
#define fill(a,v) memset(a,v,sizeof a)
#define sz(a) ((int)(a.size()))
#define mp make_pair
#define pb push_back

int main(){
	int l, r, d;
	cin>>l>>r>>d;
	int cnt = 0;
	for(int i = l; i <= r; i++) {
		if(i % d == 0) cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 3592
#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 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 zrobits(x)      __builtin_ctzll(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 w(x)            int x; cin>>x; while(x--)
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;


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

int power(int n, int x)
{
	if (x == 0)
		return 1;

	int small = power(n, x / 2) % mod;
	small = (small * small) % mod;

	if (1 & x)
		small = (n * small) % mod;

	return small;
}

bool isPowerOfTwo(int n)
{
	return n && (!(n & (n - 1)));
}

int minSteps(int height[], int n, int k)
{
	int dp[100005] = {0};
	dp[2] = abs(height[1] - height[0]);

	for (int i = 3; i <= n; i++)
	{
		dp[i] = INT_MAX;
		for (int j = 1; j <= k; j++)
		{
			if (i - j >= 1)
				dp[i] = min(dp[i], abs(height[i - 1] - height[i - 1 - j]) + dp[i - j]);
		}
	}

	return dp[n];
}


int32_t main()
{
	//d_m_c();

	int n, k;
	cin >> n >> k;

	int height[n];

	for (int i = 0; i < n; i++)
		cin >> height[i];

	cout << minSteps(height, n, k);

	return 0;
}

Measured memory_bytes: 1792
K, N = map(int, input().split())

A_list = list(map(int, input().split()))
A_gap_max = 0
ans = 0

for i in range(N-1):
    A_gap_temp = A_list[i+1] - A_list[i]
    if A_gap_temp > A_gap_max:
        A_gap_max = A_gap_temp
    ans += A_gap_temp 
A_gap_temp = A_list[0] + K - A_list[N-1]
if A_gap_temp > A_gap_max:
    A_gap_max = A_gap_temp
ans += A_gap_temp 
    
ans -= A_gap_max
print(ans)


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

int main(){
    int n;cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    double s=0;
    for(int i=0;i<n;i++){
        s+=1.0/(double)a[i];
    }
    cout<<1.0/s<<endl;
}

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

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

    vector<int> r;
    vector<int> g;
    vector<int> b;
    for(int i=0;i<N;i++){
        if(s[i]=='R') r.push_back(i);
        if(s[i]=='G') g.push_back(i);
        if(s[i]=='B') b.push_back(i);
    }

    if(r.size()<1 || g.size()<1 || b.size()<1){cout << 0 << endl; return 0;}

    long long count = r.size()*g.size()*b.size();
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            int k = 2*j-i;
            if(k>=N) continue;
            if(s[i]!=s[j] && s[j]!=s[k] && s[i]!=s[k]) count--;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 3640
fn main() {
    proconio::input! {
        n: usize,
        m: usize,
        e: [(u32, u32); m],
    }
    let mut u = petgraph::unionfind::UnionFind::new(n + 1);
    let ans = n - 1 - e.iter().filter(|p| u.union(p.0, p.1)).count();
    println!("{}", ans);
}


Measured memory_bytes: 4400
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;



int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	

	
	ins(morty);
	ins(mortyy);
	int pos = -1;
	FOR(i,0,morty.size()-mortyy.size()+1){
		if(morty[i] == '?' or morty[i] == mortyy[0]){
			int one = 0;
			FOR(i1,0,mortyy.size()){
				if(morty[i+i1] == '?' or morty[i+i1] == mortyy[i1])continue;
				else one = 1;
			}
			if(one == 0)pos =i;
		}
	}
  //out(pos);
	FOR(i,0,morty.size()){
		if(i == pos){
			FOR(i1,0,mortyy.size()){
				morty[i+i1] = mortyy[i1];
			}
			i+=mortyy.size()-1;
		}
		else if(morty[i] == '?')morty[i] = 'a';
	}

  if(pos == -1)out("UNRESTORABLE");
	else out(morty);








	return 0;
}


Measured memory_bytes: 256
/*
 *created by Kraken on 28-03-2020 at 17:05
 */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int x = sc.nextInt(), y = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
		Long[] red = new Long[a], green = new Long[b], cless = new Long[c];
		for (int i = 0; i < a; i++) red[i] = sc.nextLong();
		for (int i = 0; i < b; i++) green[i] = sc.nextLong();
		for (int i = 0; i < c; i++) cless[i] = sc.nextLong();
		Arrays.sort(red, Comparator.reverseOrder()); Arrays.sort(green, Comparator.reverseOrder());
		ArrayList<Long> arr = new ArrayList<>();
		arr.addAll(Arrays.asList(red).subList(0, x));
		arr.addAll(Arrays.asList(green).subList(0, y));
		arr.addAll(Arrays.asList(cless));
		arr.sort(Comparator.reverseOrder());
		long res = 0;
		for (int i = 0; i < x + y; i++) res += arr.get(i);
		System.out.println(res);
	}

	static class FastReader {

		BufferedReader br;

		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			}
			catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


Measured memory_bytes: 59276