akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;


int main() {
    int a,b,c;
    cin >> a >> b >>c;
    if(a+b+c>21) {
        cout << "bust";
    }else {
        cout << "win";
    }
}

Measured memory_bytes: 768
x = input().split()
a = sorted(list(map(int, input().split())), reverse=True)
n = int(x[0])
m = int(x[1])
goukei = 0
count = 0
for i in a:
  goukei += i
for i in a:
  if goukei/(4*m) <= i:
    count += 1
if count >= m:
  print('Yes')
else:
  print('No')

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

priority_queue<int, vector<int>, greater<int> > a;
priority_queue<int, vector<int>, greater<int> > b;
int main(){
  int h, w;
  cin >> h >> w;
  int tmp;
  for(int i = 0;i < h;i++){
    cin >> tmp;
    a.push(tmp);
  }

  for(int i = 0;i < w;i++){
    cin >> tmp;
    b.push(tmp);
  }

  long long ans = 0;
  while(!a.empty() && !b.empty()){
    if(a.top() < b.top()){
      ans += a.top() * (long long)(b.size());
      a.pop();
    }else{
      ans += b.top() * (long long)(a.size());
      b.pop();
    }
  }

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



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

int main(){
  int N;
  cin >> N;
  vector<vector<int>> happiness(N, vector<int>(3));
  for(int i=0; i<N; i++){
    cin >> happiness[i][0] >> happiness[i][1] >> happiness[i][2];
  }
  vector<vector<int>> DP(N, vector<int>(3));
  for(int i=0; i<3; i++){
    DP[0][i] = happiness[0][i];
  }
  for(int i=1; i<N; i++){
    for(int j=0; j<3; j++){
      DP[i][j] = max(DP[i-1][(j+1)%3], DP[i-1][(j+2)%3]) + happiness[i][j];
    }
  }
  cout << *max_element(DP[N-1].begin(), DP[N-1].end()) << endl;
}


Measured memory_bytes: 11136
import sys

def happyo(n,each_point):
  for x in range(n):
    if (each_point[x] < 1):
      print("No")
    else:
      print("Yes")

inp1 = input()
n = int(inp1.split(" ")[0])
k = int(inp1.split(" ")[1])
q = int(inp1.split(" ")[2])

if(k>100000):
  for x in range(n):
    print("Yes")
  sys.exit()

each_point = []
for i in range(n):
  each_point.append(k-q)
 

for j in range(q):
  ans = int(input())
  each_point[ans-1] += 1
 
happyo(n,each_point)

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

using namespace std;

#define FOR(i,s,e) for(int (i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)
#define RFOR(i,e,s) for(int (i)=(e)-1;(i)>=(int)(s);(i)--)
#define RREP(i,e) RFOR(i,e,0)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef pair<int, int> PII;
typedef priority_queue<int> PQI;
typedef priority_queue<PII> PQII;

const double EPS = 1e-10;
const int INF = 1e9;
const int N = 50;
const int T = 50;
int n;
int t[N];
int dp[2][N*T+1][N*T+1];

int main() {
  scanf("%d ", &n);
  REP(i,n) scanf("%d ", t+i);

  int t_sum = 0;
  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;
  int crt, nxt;
  REP(i,n) {
    crt = i&1; nxt = (i+1)&1;
    REP(j,t_sum+1)
      REP(k,t_sum+1) {
        dp[nxt][j+t[i]][k] |= dp[crt][j][k];
        dp[nxt][j][k+t[i]] |= dp[crt][j][k];
        dp[nxt][j][k] |= dp[crt][j][k];
      }
    t_sum += t[i];
    memset(dp[crt], 0, sizeof(dp[crt]));
  }

  int res = INF;
  REP(j,t_sum+1) REP(k,t_sum+1)
    if (dp[nxt][j][k]) res = min(res, max(max(j,k), t_sum-j-k));

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

  return 0;
}

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

#define REP(i, n) for (i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007            // 1e9+7
#define INF 1000000001            // 1e9+1
#define LINF 1000000000000000001  // 1e18+1

string a, b;
int i;
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);



    cin >> a;
    REP(i, 3) {
        if (a[i] == '1')
            b += '9';
        else
            b += '1';
    }
    P(b);
    return 0;
}

Measured memory_bytes: 256
/**
 *   author: malviyanshiv
 *   created: 09 January 2019  23:27:27
**/

#include <bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for(int i = a; i < b; i++)
#define RREP(i, a, b) for(int i = a-1; i >= b; i--)
#define PB push_back
#define MP make_pair
#define MOD 1000000007
#define INF 0x7fffffff
#define MAX 100005

typedef long long ll;
typedef pair< int, int > PII;

void fastscan(int &x){
    bool neg=false;
    register int c;
    x =0;
    c=getchar();
    if(c=='-'){
        neg = true;
        c=getchar();
    }
    for(;(c>47 && c<58);c=getchar())
        x = (x<<1) + (x<<3) +c -48;
    if(neg)
        x *=-1;
}

void optimizeIO(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
}

vector<int> arr;
vector< vector<int> > dp(MAX, vector<int>(2, -1));
int mini = INF;

int main(){
	optimizeIO();
    
    int n, k;
    cin >> n >> k;
    arr.resize(n);
    REP(i, 0, n){
        cin >> arr[i];
        mini = min(mini, arr[i]);
    }

    REP(i, 0, mini)
        dp[i][0] = dp[i][1] = 0;
    for(int a: arr)
        dp[a][0] = dp[a][1] = 1;

    REP(i, mini+1, k+1){
        if( dp[i][0] == -1 ){
            int &res = ( dp[i][0] = 0 );
            for(int a: arr)
                if( i >= a )
                    res = res | ( !dp[i-a][1] );
        }
        if( dp[i][1] == -1 ){
            int &res = ( dp[i][1] = 0 );
            for(int a: arr)
                if( i >= a )
                    res = res | ( !dp[i-a][0] );
        }
    }

    REP(i, 0, k+1)
        assert(dp[i][0] != -1 && dp[i][1] != -1 );
    

    if( dp[k][0] == 1 )
        cout << "First" << endl;
    else
        cout << "Second" << endl;

	return 0;
}

Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String s = scan.next();
		scan.close();
		char a='A';
		char[] c = s.toCharArray();
		for(int i=0;i<c.length;i++) {
			if(c[i]+n>=a+26) {
				c[i]=(char)(c[i]+n-26);
			}else {
				c[i]+=n;
			}
			System.out.print(c[i]);
		}
		System.out.println();
	}
}

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

using namespace std;

int main(void){
    long long N, Q;
    cin >> N >> Q;
    vector<pair<long long, long long>> v;
    v.reserve(N + Q);
    for(long long i = 0; i < N; i++){
        long long S, T, X;
        cin >> S >> T >> X;
        v.push_back(make_pair(S - X, X * N + i));
        v.push_back(make_pair(T - X, -X * N - i));
    }
    for(int i = 0; i < Q; i++){
        long long D;
        cin >> D;
        v.push_back(make_pair(D, LLONG_MAX));
    }
    sort(v.begin(), v.end());
    set<long long> restr;
    for(vector<pair<long long, long long>>::iterator itr = v.begin(); itr != v.end(); itr++){
        if(itr -> second == LLONG_MAX){
            if(restr.size() == 0) cout << -1 << endl;
            else cout << *restr.begin() / N << endl;
        }else if(itr -> second > 0){
            restr.insert(itr -> second);
        }else if(itr -> second < 0){
            restr.erase(-(itr -> second));
        }
    }
    return 0;
}


Measured memory_bytes: 21524
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll N, M;
  cin >> N >> M;

  ll ans = 1;
  for (ll i = 1; i * i <= M; i++) {
    if (M % i == 0) {
      if (M / i >= N) {
        ans = max(ans, i);
      }
      ll div = M / i;
      if (M / div >= N) {
        ans = max(ans, div);
      }
    }
  }

  cout << ans;

  return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    string s1;cin >> s1;
    int ans = 100;
    int end = 0;
    REP(j,26){
        string s = s1;
        char c = 'a' + j;
        end = 0;
        REP(x, SZ(s))
        {
            REP(k, SZ(s) - x)
            {
                if (s[k] != c)
                {
                    break;
                }
                if (k == (SZ(s) - x - 1))
                {
                    ans = min(x, ans);
                    end = 1;
                }
            }
            if (end == 1)
                break;

            REP(k,SZ(s)){
                if(s[k]==c||s[k+1]==c){
                    s[k] = c;
                }
            }
            
        }
            //cout << s <<" "<< ans<< "\n";
    }


    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 256
//21171_somesh || asomesh999

#include<bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(long long i=a;i<b;i++)
#define io ios::sync_with_stdio(false);cin.tie(NULL);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
long int mod=1000000007;

int main()
{
	io
	#ifdef CODE
		clock_t startTime = clock();
		freopen("input.txt","r",stdin);
	#endif

	int p, n;
	cin >> p >> n;
	vi arr(p);
	ll penalties = 0, ac = 0;
	fr(i, 0, n) {
		int x;
		cin >> x;
		x--;
		string s;
		cin >> s;
		if (s == "WA" && arr[x] != -1) {
			arr[x]++;
		} else {
			if (arr[x] > 0) {
				penalties += arr[x];
			} 
			if (arr[x] != -1) {
				ac++;
				arr[x] = -1;
			}
		}
	} 
	cout << ac << ' ' << penalties;
	

	#ifdef CODE
		cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;
	#endif
	return 0;
}

Measured memory_bytes: 640
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [float("inf") for _ in range(n)]
dp[0] = 0

for i in range(n-1):
    for j in range(1, min(k+1, n-i)):
        dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]))

print(dp[n-1])

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

int main() {
    while(1) {
      int n; cin >> n;
      if(n == 0) return 0;
      rep(i, 9) {
        int m; cin >> m;
        n -= m;
      }
      cout << n << endl;
    }
}


Measured memory_bytes: 2972
const double = Float64
const int = Int64
const vint = Vector{int}
const vdouble = Vector{double}

int(x) = parse(int,x)
parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))


function check(B,C,A,X,c)
  N,M = size(A)
  S = zeros(int,M)
  t = 0
  for i in 1:N
    B[i]==0 && continue
    t += C[i]
    for j in 1:M
      S[j] += A[i,j]
    end
  end
  flag = true
  for i in 1:M
    if S[i] < X
      flag = false
      break
    end
  end
  if flag == false || t > c
    return c
  else 
    return t
  end
end

function rec(B,p,A,C,X,c)
  if length(B) == p
    return check(B,C,A,X,c)
  end

  p += 1
  for i in 0:1
    B[p] = i
    c = rec(B,p,A,C,X,c)
  end
  return c
end

function main()
  N, M, X  = readint()
  
  C = zeros(int, N)
  A = Array{int,2}(undef, N,M)
  for i in 1:N
    B = readint()
    C[i] = B[1]
    A[i,:] .= B[2:M+1]

    #println(A[i,:])
    #readint()
  end

  B = zeros(int,N)
  c = rec(B,0,A,C,X,10^8)

  if c == 10^8
    println("-1")
  else
    println(c)
  end
 
end

main()

Measured memory_bytes: 249328
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>
#include <set>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d\n",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

int main(void)
{

	string str;
	cin >> str;

	cout << count(str.begin(), str.end(), 'o') * 100 + 700 << endl;

	return 0;
}


Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include<bits/stdc++.h>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int maxn=200111;
int n,a[maxn],nxt[maxn],pos[maxn];
LL k;
int f[60][maxn];LL fv[60][maxn];

int getv(LL&k)
{
	int ret=1;
	for(int i=59;i>=0;i--)if(fv[i][ret]<=k)
	{
		k-=fv[i][ret];
		ret=f[i][ret];
	}
	return ret;
}

bool have[maxn];
int stk[maxn],top;
void add(int x)
{
	if(!have[x])
	{
		have[x]=1;
		stk[++top]=x;
	}
	else
	{
		while(stk[top]!=x)
		{
			have[stk[top]]=0;
			top--;
		}
		top--;
		have[x]=0;
	}
}

int main()
{
	scanf("%d%lld",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	for(int i=n;i>=1;i--)pos[a[i]]=i;
	for(int i=n;i>=1;i--)
	{
		nxt[i]=pos[a[i]];
		pos[a[i]]=i;
	}
	for(int i=1;i<=n;i++)
	{
		f[0][i]=nxt[i]+1;fv[0][i]=(nxt[i]<=i);
		if(f[0][i]>n)
		{
			f[0][i]=1;
			fv[0][i]++;
		}
	}
	for(int i=1;i<60;i++)for(int j=1;j<=n;j++)
	{
		f[i][j]=f[i-1][f[i-1][j]];
		fv[i][j]=fv[i-1][j]+fv[i-1][f[i-1][j]];
	}
	k--;
	int cur=getv(k);
	for(int i=cur;i<=n;i++)add(a[i]);
	if(k)
	{
		for(int i=1;i<=n;i++)add(a[i]);
	}
	for(int i=1;i<=top;i++)printf("%d ",stk[i]);puts("");
	return 0;
}

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

#define PI 3.14159265358979323846264338327950L
#define ll long long
#define lli long long int

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x, n;
    cin >> x >> n;
    unordered_set<int> sets;
    for (int i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        sets.insert(temp);
    }
    int counts = 0;
    int value = x;
    int answer;
    while (true) {
        if (counts % 2 == 0) {
            value += counts;
            if (sets.find(value) == sets.end()) {
                answer = value;
                break;
            }
        } else {
            value -= counts;
            if (sets.find(value) == sets.end()) {
                answer = value;
                break;
            }
        }
        counts++;
    }
    cout << answer << "\n";
    return 0;
}


Measured memory_bytes: 3656
from sys import stdin
from itertools import repeat
def f(a):
    n = len(a)
    l = [0] * (n + 1)
    st = [(a[0], a[0], 1)]
    pu = st.append
    po = st.pop
    for i in xrange(1, n):
        ad = 0
        y = a[i]
        k = 1
        while st and y > st[-1][0]:
            x, z, q = po()
            c = (((y - 1) / x).bit_length() + 1) / 2 * 2
            ad += c * q
            k += q
            y = z << c
        pu((a[i], y, k))
        l[i+1] = l[i] + ad
    return l
 
def main():
    n = int(stdin.readline())
    a = map(int, stdin.readline().split(), repeat(10, n))
    l = f(a)
    r = f(a[::-1])[::-1]
    ans = 10 ** 12
    for i in xrange(n + 1):
        if ans > l[i] + i + r[i]:
            ans = l[i] + i + r[i]
    print ans
main()


Measured memory_bytes: 36168
import Data.Char

main = do
  s <- map charToDigit <$> getLine
  putStrLn . show $ analyze s 0 0

charToDigit x = ord x - ord '0'

analyze :: [Int] -> Int -> Int -> Int
analyze n sum buf
  | length n == 0 = sum + buf
  | otherwise = (analyze tail' (sum+buf) 0) + (analyze tail' sum (10*buf + head'))
  where
    head' = head n
    tail' = tail n


Measured memory_bytes: 380
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())
arrA = list(map(int,input().split()))
# arrA = np.array(input().split(),dtype=np.int64)

cnt = Counter(arrA)
ans = 0
lis = sorted(list(cnt.items()))
n = len(lis)

shrt = 0
lng = 0
for i in range(n):
    if lis[i][1]>=4:
        shrt = lis[i][0]
        lng = lis[i][0]
        ans = max(ans,lng*shrt)
    elif shrt == 0 and lis[i][1]>=2:
        shrt = lis[i][0]
    elif lis[i][1]>=2:
        lng = lis[i][0]
        ans = max(ans,lng*shrt)
        shrt = lng
    else:
        pass

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 22044
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[5];
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
  int min;
  bool found = false;
  for(int i = 0; i < 5; i++){
    if(a[i] % 10 != 0){
      if(!found){
        min = i;
        found = true;
      }else{
        if(a[min] % 10 > a[i] % 10){
          min = i;
        }
      }
    }
  }
  int ans = 0;
  if(found){
    for(int i = 0; i < 5; i++){
      if(i == min){
        ans += a[i];
      }else if(a[i] % 10 == 0){
        ans += a[i];
      }else{
        ans += (a[i] / 10 + 1) * 10;
      }
    }
  }else{
    ans = a[0] + a[1] + a[2] + a[3] + a[4];
  }
  cout<< ans <<endl;
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> h(N, 0);
    int max_hight = 0;
    for (int i = 0; i < N; i++) {
        cin >> h[i];
        max_hight = max(max_hight, h[i]);
    }
    int ans = 0;
    for (int hight = 1; hight <= max_hight; hight++) {
        int count = 0;
        for (int i = 0; i < h.size(); i++) {
            if (h[i] >= hight) {
                int j = i;
                while (j < h.size() && h[j] >= hight) {
                    j++;
                }
                count++;
                i = j;
            }
        }
        ans += count;
    }
    cout << ans << endl;
    return 0;
}

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

A0 = list(map(int,input().split()))

A=sorted(A0)
A.append(0)

N1={}

c = 1
for i in range(N):
#    print(A[i],A[i+1])
    if A[i] == A[i+1]:
        c += 1
    else:
        N1[A[i]] = c
        c = 1
#mydict["peach"] = 4
#print(A)
#print(N1)

N2={}
for i in N1.keys():
#    print(i,N1[i])
    if N1[i] ==1:
        N2[i] = (0,0)
    else:
        N2[i] = (N1[i]*(N1[i]-1)/2,(N1[i]-1)*(N1[i]-2)/2)

T1 = 0
for i in N2.keys():
    T1 += N2[i][0]

for i in range(N):
    T2 = int(T1 - N2[A0[i]][0]+N2[A0[i]][1])
    print(T2)
        
    




Measured memory_bytes: 97612
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import product
def main():
    x = int(input())
    n5 = [i**5 for i in range(1000)]
    c = product(n5, repeat=2)
    for ce in c:
        if ce[0] + ce[1] == x:
            r = (int(ce[0]**0.2), int(ce[1]**0.2)* -1)
            break
        elif ce[0] - ce[1] == x:
            r = (int(ce[0] ** 0.2), int(ce[1] ** 0.2))
            break
    print(*r, sep=' ')
if __name__ == '__main__':
    main()

Measured memory_bytes: 9312
#include<bits/stdc++.h>
using namespace std ;
typedef long long int ll ;
typedef long double ld ;
typedef vector< ll > vi ;
typedef pair<ll, ll > ii ;
#define pb push_back
#define mp make_pair
#define EPS 1e-8
#define se second
#define fi first
#define mod 1000000007
int main()
{
    ll n , m ;
    cin >> n >> m ;
    ll a[n+1] ;
    for(int i = 0 ; i < n ; i++ )
    {
        cin >> a[i] ;
    }
    ll ans = 0 , aux = 0 ;
    ans = 0 ;
    for(int i = 0 ; i < n ; i++ )
    {
        if(a[i] < aux){
            ans += a[i]+m - aux ;
            aux  = m + a[i] ;
        }
        else{
            ans += m ;
            aux = a[i]+m;
        }
    }
    cout << ans <<endl ;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=10000000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ull b=10009;
    ll n;cin>>n;
    string s;cin>>s;
    rrep(i,n,1){
        //if(i*2>n)continue;
        ull t=1;
        rep(j,0,i){
            t*=b;
            t%=mod;
        }
        ull ha[n];
        fill(ha,ha+n,-1);
        ull ah=0;
        rep(j,0,i){
            ah=ah*b+s[j];
            ah%=mod;
        }
        rep(j,0,n){
            ha[j]=ah;
            if(j+i>=n)break;
            ah=ah*b+s[j+i];
            ah%=mod;
            ull r=s[j]*t;
            r%=mod;
            ah-=r;
            ah+=mod;
            
            ah%=mod;
        }
        //rep(j,0,n)cout<<ha[j]<<endl;
        unordered_map<ll,ll> mp;
        rep(j,i,n){
            if(j+i>n)break;
            mp[ha[j-i]]=1;
            if(mp[ha[j]]==1){
                cout<<i<<endl;
                return 0;
            }
        }
    }
    cout<<0<<endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n, bNum = 0, ans = 0;
string s;

int main() {
	cin >> n;
	cin >> s;
	rep(i, n) {
		if (s[i] == 'B')bNum++;
	}
	rep(i, n) {
		if (s[i]=='R') {
			rep(j, n) {
				if (s[j]=='G') {
					ans += bNum;
					if (min(i, j) - abs(i - j) >= 0 && s[min(i, j) - abs(i - j)] == 'B')ans--;
					if (max(i, j) + abs(i - j) < n && s[max(i, j) + abs(i - j)] == 'B')ans--;
					if (!((i - j) % 2) && s[(i + j) / 2] == 'B')ans--;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
import os
import heapq
import sys,threading
import math as mt
import operator
from copy import copy
from collections import defaultdict,deque
from io import BytesIO, IOBase

sys.setrecursionlimit(2*10 ** 5)
#threading.stack_size(2**27)


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


def pw(a,b,md):
    result=1
    while(b>0):
        if(b%2==1):
            result*=a
            result%=md
        a*=a
        a%=md
        b//=2
    return result%md


def inpt():
    return [int(k) for k in input().split()]

def main():
    md=10**9+7
    n=int(input())
    ar=[0,0,0,1]
    if(n<3):
        print(0)
        exit()
    for i in range(4,n+1):
        temp=1
        for j in range(3,i):
            temp+=ar[i-j]
            temp%=md
        ar.append(temp)
    print(ar[len(ar)-1])




BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()
    #threading.Thread(target=main).start()


Measured memory_bytes: 75340
#include <cstdio>
#include <algorithm>
#define MAX 2000000
#define INF (1<<30)

int h, A[MAX+1];

void maxHeapify(int i) {
    int l, r, largest;
    l = i * 2;
    r = l + 1;

    if (l <= h && A[l] > A[i]) largest = l;
    else largest = i;
    if (r <= h && A[r] > A[largest]) largest = r;

    if (largest != i) {
        std::swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

void increaseKey(int i, int k) {
    if (k < A[i]) return;
    A[i] = k;
    while (i > 1 && A[i / 2] < A[i]) {
        std::swap(A[i], A[i / 2]);
        i = i / 2;
    }
}

void insert(int k) {
    h++;
    A[h] = -INF;
    increaseKey(h, k);
}

int extract(void) {
    if (h < 1) return -INF;
    int m = A[1];
    A[1] = A[h];
    h--;
    maxHeapify(1);
    return m;
}

int main(void) {
    int i, k;
    char com[10];
    
    while (1) {
        scanf("%s", com);
        if (com[0] == 'e' && com[1] == 'n') break;
        if (com[0] == 'i') {
            scanf("%d", &k);
            insert(k);
        }
        if (com[0] == 'e') {
            printf("%d\n", extract());
        }
    }

    return 0;
}

Measured memory_bytes: 5128
import java.io.PrintWriter;
import java.util.*;

public class Main {

	static int c;
	static int[] w;
	static int[] v;
	static long[][] dp;
	static int n;

	public static long KnapSack(int idx, int remw) {
		if (remw < 0) {
			return -(int) 1e9;
		}
		if (idx == n) {
			return 0;
		}
		if (dp[idx][remw] != -1) {
			return dp[idx][remw];
		}
		long take = v[idx] + KnapSack(idx + 1, remw - w[idx]);
		long leave = KnapSack(idx + 1, remw);
		return dp[idx][remw] = Math.max(take, leave);
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		n = sc.nextInt();
		c = sc.nextInt();
		w = new int[n];
		v = new int[n];
		dp = new long[n][c+1];
		for (long[] x : dp)
			Arrays.fill(x, -1);
		for (int i = 0; i < n; i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
		}
		pw.println(KnapSack(0, c));
		pw.close();
	}

}

Measured memory_bytes: 131960
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
const double pi = 3.1415926535;
void solve(){
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double v1 = 30 * h + 0.5 * m;
    double v2 = 6 * m;
    double diff = abs(v1 - v2);
    diff = diff * pi / 180.0;
    double theta = diff;
    double ans = a * a + b * b - 2 * a * b * cos(theta);
    ans = sqrt(ans);
    cout << setprecision(10) << ans << endl;
    

}

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

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

int n,arr[100007],dp[100007],k;

int solve(int y)
{
    if(y==n-1) return 0;
    if(dp[y]!=-1) return dp[y];
    dp[y]=INT_MAX;
    for(int i=1;y+i<n&&i<=k;i++)
    {
        dp[y]=min(dp[y],solve(y+i)+abs(arr[y]-arr[y+i]));
    }
    return dp[y];
}

int main()
{
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++)
        scanf("%d",&arr[i]);
    memset(dp,-1,sizeof(dp));
    printf("%d\n",solve(0));
    return 0;
}


Measured memory_bytes: 4096
import java.math.BigInteger;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		BigInteger A = new BigInteger(sc.next()), B = new BigInteger(sc.next());
		sc.close();
		System.out.println(A.divide(B));
	}
}


Measured memory_bytes: 26500
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        String word = s.next();
        if(word.equals("ABC")) System.out.println("ARC");
        else System.out.println("ABC");
        
    }
}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

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

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

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


int main(){
    int a, b, c, x = 0;
    cin >> a >> b >> c;
    if (a==b){
        x++;
    }
    if (b==c){
        x++;
    }
    if (c==a){
        x++;
    }
    if (x==1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
def main():
	n, s, *a = map(int, open(0).read().split())
	ans = 0
	mod = 998244353
	dp = [0] * (s + 1)
	for i, x in enumerate(a):
		dp[0] += 1
		if x > s:continue
		ans += dp[s - x] * (n - i)
		ans %= mod
		dp = dp[:x] + [(dp[j] + dp[j - x]) % mod for j in range(x, s + 1)]
	print(ans)
	
if __name__=="__main__":
	main()



Measured memory_bytes: 3440
#include <iostream>
#include <set>
#include <list>
#include <utility>
#include <queue>
#include <memory>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>

using namespace std; 

int
main(int argc, char const *argv[])
{
    int64_t n;
    cin >> n;
    vector<tuple<int64_t, int64_t>> v(n);

    int64_t sum = 0;
    for (int64_t i = 0; i < n; ++i) {
	int64_t a, b;
	cin >> a >> b;
	v[i] = make_tuple(a, b);
	sum = sum + a;
    }

    std::sort(
        v.begin(),
        v.end(),
        [](const tuple<int64_t, int64_t>& x, const tuple<int64_t, int64_t>& y){
	    return get<1>(x) > get<1>(y) || ((get<1>(x) == get<1>(y)) && get<0>(x) > get<0>(y));
	}
    );

    // cout << sum << endl;
    
    bool res = true;
    for (int64_t i = 0; i < n; ++i) {
	// cout << sum << "|" << get<0>(v[i]) << " : " << get<1>(v[i]) << endl;
	if (get<1>(v[i]) < sum) {
	    res = false;
	    break;
	}
	sum = sum - get<0>(v[i]);
    }

    if (res) {
	cout << "Yes" << endl;
    } else {
	cout << "No" << endl;
    }


    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{
    string s,t,u;
    int a,b;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    if(s==u)
    {
        a=a-1;
    }
    else
    {
        b=b-1;;
    }
    cout<<a<<" "<<b<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int n;
long long sum[3003][3003];
long long dp[3003][3003];
long long a[3003];
 
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j++){
			sum[i][j] = sum[i][j-1] + a[j];
		}
	}
	
	for(int j=1;j<=n;j++){
		for(int i=j;i>0;i--){
			dp[i][j] = max(a[j] + sum[i][j-1] - dp[i][j-1],a[i] + sum[i+1][j] - dp[i+1][j]);
		}
	}
	
	cout<<2*dp[1][n]-sum[1][n]<<endl;
	
	return 0;
}


Measured memory_bytes: 139776
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n;
    int ans = 0;
    cin >> n;
    vector<ll> arr(n, 0);
    for(int i = 0; i < n; i++) {
        cin >> arr[i];
        while (arr[i] % 2 == 0) {
            arr[i] /= 2;
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 384
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p,lc,rc,br,deg,h;}; 
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];

void print(int u){
  int i, c;
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",u,T[u].p,T[u].br,T[u].deg,D[u],T[u].h);

  if(T[u].p==NIL) printf("root\n");
  else if(T[u].lc==NIL && T[u].rc==NIL) printf("leaf\n");
  else printf("internal node\n");
  
}

int calcDepth(int u, int p){
  int lh=NIL,rh=NIL;
  D[u] = p;
  
  if(T[u].rc!=NIL) rh=calcDepth(T[u].rc,p+1);  
  if(T[u].lc!=NIL) lh=calcDepth(T[u].lc,p+1);

  if(T[u].deg==0) T[u].h=0;
  else if(lh<=rh) T[u].h=rh+1;
  else T[u].h=lh+1;

  return T[u].h;
}

int main(){
  int i, j, k;
  int n;
  int id, sib, lc,rc;
  int root = NIL;
  scanf("%d", &n);
  for(i=0; i<n; i++) T[i].p = T[i].lc = T[i].rc = T[i].br = T[i].h = NIL;
  
  for(i=0; i<n; i++){
    scanf("%d", &id);
    scanf(" %d %d",&T[id].lc, &T[id].rc);

    T[id].deg=0;
    
    if(T[id].lc!=-1){
      T[T[id].lc].p=id;
      T[id].deg++;
    }
    if(T[id].rc!=-1){
      T[T[id].rc].p=id;
      T[id].deg++;
    }
    T[T[id].lc].br=T[id].rc;
    T[T[id].rc].br=T[id].lc;
  }

  //根を求める (find the root)
  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }
  
  //それぞれのノードの深さを求める (find depth of each node)
  calcDepth(root, 0);

  //出力 (output)
  for(i=0; i<n; i++) print(i);
  
  return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

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

int cmp(const string &a, const string &b){
    int i=0, j=0;
    while(i < a.size() && a[i] == '0') ++i;
    while(j < b.size() && b[j] == '0') ++j;
    if(a.size()-i < b.size()-j) return 1;
    else if(a.size()-i > b.size()-j) return -1;
    else{
        while(i < a.size()){
            if(a[i] < b[j]) return 1;
            else if(a[i] > b[j]) return -1;
            ++i;
            ++j;
        }
        return 0;
    }
}

int main(){
    int w, h;
    while(scanf("%d%d", &w, &h) && w){
        char c[h][w];
        rep(i, h)rep(j, w) scanf(" %c", &c[i][j]);
        string s[h][w];
        string ans = "0";
        rep(x, h)rep(y, w)if(isdigit(c[x][y])){
            s[x][y] = c[x][y];
            rep(i, 2){
                int nx = x + dx[i], ny = y + dy[i];
                if(0<=nx && nx<h && 0<=ny && ny<w && isdigit(c[nx][ny])){
                    string tmp = s[nx][ny] + c[x][y];
                    int cur = 0;
                    while(cur < tmp.size() && tmp[cur] == '0') ++cur;
                    tmp = tmp.substr(cur);
                    if(cmp(s[x][y], tmp) == 1) s[x][y] = tmp;
                }
            }
            if(cmp(ans, s[x][y]) == 1) ans = s[x][y];
        }
        cout << ans << "\n";
    }
}


Measured memory_bytes: 3236
n=int(input())
lists=[[ 0 for j in range(10)]for i in range(10)]
for i in range(1,n+1):
    a=str(i)
    lists[int(a[0])][int(a[-1])]+=1
c=0
for i in range(1,10):
    for j in range(1,10):
        c+=lists[i][j]*lists[j][i]
print(c)        

        

Measured memory_bytes: 3060
import math

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
n,k = map(int,input().split())

a = list(map(int,input().split()))

b = a[0]

for i in a:
    b = gcd(b,i)

if k > max(a) or k%b != 0:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

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

int main()
{
  int64_t A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  vector<int64_t> DP(3010, -1);
  A *= 100;
  B *= 100;
  DP.at(0) = 0;
  for (int w = 1; w <= F; w++) // 全量wにおける砂糖の重量sの最大値を求める
  {
    int64_t s = -1, a = -1, b = -1, c = -1, d = -1; // -1は実現不可能性を示す
    if (w - A >= 0 && DP.at(w - A) != -1)
    {
      a = DP.at(w - A);
      s = a;
    }
    if (w - B >= 0 && DP.at(w - B) != -1)
    {
      b = DP.at(w - B);
      if (b > s)
        s = b;
    }
    if (w - C >= 0 && DP.at(w - C) != -1)
    {
      int64_t sugar = DP.at(w - C) + C;
      if (100 * sugar <= (w - sugar) * E && ((w - sugar) % A) % B == 0)
        c = sugar;
      if (c > s)
        s = c;
    }
    if (w - D >= 0 && DP.at(w - D) != -1)
    {
      int64_t sugar = DP.at(w - D) + D;
      if (100 * sugar <= (w - sugar) * E && ((w - sugar) % A) % B == 0)
        d = sugar;
      if (d > s)
        s = d;
    }
    DP.at(w) = s;
  }
  int64_t s = 0, sw = 0;
  long double maxp = 0, p = 0;
  for (int i = 1; i <= F; i++)
  {
    if (DP.at(i) != -1)
    {
      long double dw = i;
      long double ds = DP.at(i);
      p = ds / dw;
      if (p >= maxp)
      {
        maxp = p;
        s = DP.at(i);
        sw = i;
      }
    }
  }
  cout << sw << ' ' << s << endl;
}


Measured memory_bytes: 256
//============================================================================
// Name        : Hello.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main() {

	int a,b;
	cin>>a>>b;

	if(b%a==0) cout<<a+b<<endl;
	else cout<<b-a<<endl;

	return 0;
}


Measured memory_bytes: 256
S = input()

if S == "SAT":
  print(1)
elif S == "SUN":
  print(7)
elif S == "MON":
  print(6)
elif S == "TUE":
  print(5)
elif S == "WED":
  print(4)
elif S == "THU":
  print(3)
else:
  print(2)
  

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

int main() {
    int n, k;
    cin >> n >> k;
    int count = 0;
    while (n != 0) {
        n /= k;
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int N;
    cin >> N;
    LL ans = 1;
    ans = N *N * N;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define drep(i,a,b) for(int i=(a); i>=(b);i--) 

const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7;


int main()
{
   ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);
   int a,b,c;
   cin >> a >> b >> c;
   int d = a - b;
   cout << max(0,c - d) << endl;
   return 0;
}

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


int main(){
    int a, b;
    cin >> a >> b;
    int cnt = 0;
    int out = 1;
    while (out < b){
        out --;
        out += a;
        cnt ++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e6+20;
ll a[N];
int main()
{
	int n;
	while(cin>>n)
	{
		for(int i=0;i<3*n;i++)
			scanf("%I64d",&a[i]);
		sort(a,a+3*n);
		ll ans=0,cnt=0;
		for(int i=3*n-2;i>=0;i-=2)
		{
			ans+=a[i];
			cnt++;
			if(cnt==n)
			break;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 4352
from math import sin,cos,tan,radians
A,B,H,M =map(int,input().split())

the_min = radians( (M/60)*360)
the_hour = radians( (H/12)*360 + 30* (M/60) )

a = [A*sin(the_hour),A*cos(the_hour)]
b = [B*sin(the_min),B*cos(the_min)]

s = (a[0]-b[0])**2 + (a[1]-b[1])**2
print(s**0.5)

Measured memory_bytes: 9540
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


h, w = LI()
M = [SI() for _ in range(h)]

d = ((0, 1), (-1, 1), (-1, 0), (-1, -1),
     (0, -1), (1, -1), (1, 0), (1, 1))

ans = []
for y in range(h):
    row = ''
    for x in range(w):
        cnt = 0
        if M[y][x] == '#':
            row += '#'
            continue

        for dy, dx in d:
            yy, xx = y + dy, x + dx
            if 0 <= yy < h and 0 <= xx < w:
                if M[yy][xx] == '#':
                    cnt += 1
        row += str(cnt)
    ans.append(row)

print(*ans, sep='\n')


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

int main(int argc, char *argv[])
{
    string str;
    int res = 0;
    while (1)
    {
        cin >> str;
        res = 0;
        if (str == "0")
            break;
        for (unsigned i = 0; i < str.size(); i++)
        {
            res += str[i] - '0';
        }
        printf("%d\n", res);
    }
    return 0;
}



Measured memory_bytes: 3268
import java.util.*;

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

        while (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();

            if (h == 0 && w == 0)
                break;

            char rect[][] = new char[h][w];
            for (char[] e : rect)
                Arrays.fill(e, '#');

            int h2 = h - 2;
            int w2 = w - 2;
            for (int x = 0; x < w2; x++)
                for (int y = 0; y < h2; y++)
                    rect[y+1][x+1] = '.';

            for (char[] e : rect)
                System.out.println(e);
            System.out.println();
        }
    }
}

Measured memory_bytes: 27068