akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if (int(X/n)):
    return Base_10_to_n(int(X/n), n)+[X%n]
  return [X%n]


#############
# Main Code #
#############

N,Z,W = inputIL()
A = inputIL()

if len(A) ==1:
  print(abs(A[0]-W))
  exit()
print(max(abs(A[-1]-W),abs(A[-2]-A[-1])))


Measured memory_bytes: 38640
import sys
import math

A,B = map(int,input().split())
if not ( 2 <= A <= 20 and 1 <= B <= 20 ): sys.exit()

if B == 1: print(0);sys.exit()
for I in range(math.ceil(B/A),21):
    if I*A-(I-1) >= B:
        print(I)
        sys.exit()

Measured memory_bytes: 9044
#include<iostream>
#include<cstdio>
#include<vector>

using namespace std;



int bottomUp(const vector<vector<int> > w, vector<vector<int> > dp)
{
	int i, j, x, n, max_val;
	n = w.size();

	dp[0][0] = w[0][0];
	dp[0][1] = w[0][1];
	dp[0][2] = w[0][2];


	for(i = 1; i < n;i++)
	{
		max_val = 0;
		dp[i][0] = max(dp[i-1][1] + w[i][0], dp[i-1][2] + w[i][0]);
		dp[i][1] = max(dp[i-1][0] + w[i][1], dp[i-1][2] + w[i][1]);
		dp[i][2] = max(dp[i-1][0] + w[i][2], dp[i-1][1] + w[i][2]);
	}

	return max(max(dp[n-1][0], dp[n-1][1]), dp[n-1][2]);
}


int main()
{
	int n;
	vector<vector<int> >w, dp;

	cin>>n;
	w.resize(n);
	dp.resize(n);

	for(int i = 0;i < n;i++)
	{
		w[i].resize(3);
		dp[i].resize(3);
		
		cin>>w[i][0]>>w[i][1]>>w[i][2];
	}

	cout<<bottomUp(w, dp)<<'\n';
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) puts("Bad");
  else puts("Good");
  return 0;
}

Measured memory_bytes: 256
/*input

*/

#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <iomanip>
#include <utility>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define pb                push_back
#define pp                pop_back
#define nl                cout << "\n"
#define MIN(con)          (*min_element(ALL(con)))
#define MAX(con)          (*max_element(ALL(con)))
#define NX(cont)          next_permutation(ALL(cont))
#define PX(cont)          prev_permutation(ALL(cont))
#define prec(n)           cout << fixed << setprecision(n)
#define PI                3.14159265358979323846264338327951
#define all(c)            c.begin(),c.end()
#define rep(i,a,b)        for(ll i=a;i<b;i++)
#define sp                cout << " "
#define mod               1000000007    //9
#define ifalse            ios_base::sync_with_stdio(false),cin.tie(NULL)

using ll = long long;
using ld = long double;
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > string toString(T a)       { return to_string(a); }  // Convert int to string
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}  // Convert string to int

ll add(ll x, ll y) { x += y; if(x >= mod) x -= mod; return x; }
ll sub(ll x, ll y) { x -= y; if(x < 0) x += mod; return x; }
ll mul(ll x, ll y) { return ((x % mod) * (y % mod)) % mod; }

ll powr(ll a, ll b) {
    ll x = 1LL;
    while(b) {
        if(b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}

ll inv(ll a) { return powr(a, mod - 2); }
const int inv2 = (mod + 1) >> 1;
const ll INF =  1e18;
const int inf = 1e9;

bool check(ll n)
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;
    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

/*********************************************START**************************************************************/

int main()
{
    ifalse;
    int n;
    cin >> n;
    ll g = 0;
    for(int i = 0; i < n; i ++) {
        ll x;
        cin >> x;
        g = GCD(x, g);
    }
    cout << g;
    return 0;
}

Measured memory_bytes: 256
<?php

  list($n) = explode(" ", trim(fgets(STDIN)));

  if($n<=9){
    echo $n;
    exit;
  }

  $count=9;
  for($i=2;$i<=10;$i++){
    for($j=1;$j<=9;$j++){
      $count=f($count, $n, $i, $j, $j);    
    }
  }

  function f($count, $n, $maxlen, $value, $pattern){
    if(strlen($pattern)==$maxlen){
      $count++;
      if($n == $count){
        echo $pattern;
        exit;
      }
//      echo $count." ".$pattern.PHP_EOL;
      return $count;
    }
    else{
      if($value==0){
        $count=f($count, $n, $maxlen, $value, $pattern.$value);
        $count=f($count, $n, $maxlen, $value+1, $pattern.($value+1));
      }else if($value==9){
        $count=f($count, $n, $maxlen, $value-1, $pattern.($value-1));
        $count=f($count, $n, $maxlen, $value, $pattern.$value);
      }else{
        $count=f($count, $n, $maxlen, $value-1, $pattern.($value-1));
        $count=f($count, $n, $maxlen, $value, $pattern.$value);
        $count=f($count, $n, $maxlen, $value+1, $pattern.($value+1));
      }
      return $count;
    }
  }

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

#define pb push_back
#define all(a) (a).begin(), (a).end()

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

const int MOD = 2019;

int main() {
	ios::sync_with_stdio(false);cin.tie(nullptr);
	string S; cin >> S;
	int n = S.size();
	vector<int> cnt_mod(MOD);

	cnt_mod[0] = 1;
	int suffix_sum = 0, p = 1;
	ll ans = 0;
	for (int i = n - 1; i >= 0; --i) {
		suffix_sum += p * (S[i] - '0');
		suffix_sum %= MOD;
		ans += cnt_mod[suffix_sum];
		p *= 10;
		p %= MOD;
		++cnt_mod[suffix_sum];
	}

	cout << ans << '\n';

}
 


Measured memory_bytes: 3756
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	int k,t,i,s=0,x,max=0;
	cin>>k>>t;
	for(i=0;i<t;i++){
		cin>>x;
		if(x>max) max=x;
		s+=x;
	}
	s-=max;
	if(max-1>s) cout<<max-s-1<<endl;
	else cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long

const int N=1005;
const int MOD=1e9+7;
 

// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
 
int32_t main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
*/

int n,m;
cin>>n>>m;
int sum=0;
int arr[n];
int b[n];
for(int i=0;i<n;i++)
{
	cin>>arr[i];
	sum+=arr[i];
}
int count=0;
for(int i=0;i<n;i++)
{
	b[i]=sum-4*m*arr[i];
	if(b[i]<=0)
	count++;
}


if(count>=m)
cout<<"Yes";
else
cout<<"No";

}



Measured memory_bytes: 256
def sort_MxMn(SeriesA):
    global max_a, min_a
    listA = list(str(SeriesA))
    while len(listA) < b:
        listA.append("0")
    listA = [int(x) for x in listA]
    max_a = sorted(listA, reverse=True)
    min_a = sorted(listA)

def translate(listEx):
    num = 0
    for i in range(b):
        num += listEx[i]*(10 ** (b-i-1))
    return num

for k in range(100000):
    a, b = map(int, input().split())
    if a + b ==0:
        break
    c = []
    for i in range(100000):
        c.append(a)
        sort_MxMn(a)
        a = translate(max_a) - translate(min_a)
        if (a in c) == True:
            print("{} {} {}".format(c.index(a), a, i - c.index(a) + 1))
            break



Measured memory_bytes: 5604
s_1 = input()
s_2 = input()

#dp[i][j] := s_1の左からiまでとs_2の左からjまでで最大の連続共通部分列の長さ
dp = [[0] * (len(s_2)+1) for _ in range(len(s_1)+1)]
for i in range(len(s_1)+1):
    dp[i][0] = i
for j in range(len(s_2)+1):
    dp[0][j] = j

for i in range(len(s_1)):
    for j in range(len(s_2)):
        if s_1[i] == s_2[j]:
            cost = 0
        else:
            cost = 1
        dp[i+1][j+1] = min(dp[i][j+1]+1, dp[i+1][j]+1, dp[i][j] + cost)

print(dp[len(s_1)][len(s_2)])


Measured memory_bytes: 43072
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            String S = reader.readLine();

            if (S.equals("Sunny")) {
                System.out.println("Cloudy");
            } else if (S.equals("Cloudy")) {
                System.out.println("Rainy");
            } else {
                System.out.println("Sunny");
            }
        }
    }

}


Measured memory_bytes: 18772
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, x;
  cin >> a >> b;
  x = a * b;  
  if (x % 2 == 1) {
    cout << "Odd" << endl;
  } else {
    cout << "Even" << endl;
  } 
}

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

const long long INF = 1e9;
const long long MAX_E = 1e8;
const int MAX_N = 100001;

int par[MAX_N];
int rank_[MAX_N];

void init(int n){
    for(int i = 0; i < n; i++){
        par[i] = i;
        rank_[i] = 0;
    }
}

int find(int x){
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
}

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(rank_[x] < rank_[y]) par[x] = y;
    else{
        par[y] = x;
        if(rank_[x] == rank_[y]) rank_[x]++;
    }
}

bool same(int x, int y){
    return find(x) == find(y);
}

struct edge{int u, v; long long cost;};

bool comp(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;
}

edge es[MAX_E];
int V;
long long E;

long long kruskal(){
    sort(es, es+ E, comp);
    init(V);
    long long res = 0;
    for(int i = 0; i < E; i++){
        edge e = es[i];
        if(!same(e.u, e.v)){
            unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> V;
    long long x[V], y[V];
    vector<pair<long long, int>> xv, yv;
    for(int i = 0; i < V; i++){
        long long x, y;
        cin >> x >> y;
        xv.emplace_back(x, i);
        yv.emplace_back(y, i);
    }
    sort(xv.begin(), xv.end());
    sort(yv.begin(), yv.end());
    long long id = 0;
    for(int i = 0; i < V-1; i++){
        edge e;
        e.u = xv[i].second;
        e.v = xv[i+1].second;
        e.cost = xv[i+1].first - xv[i].first;
        es[id] = e;
        id++;
    }
    for(int i = 0; i < V-1; i++){
        edge e;
        e.u = yv[i].second;
        e.v = yv[i+1].second;
        e.cost = yv[i+1].first - yv[i].first;
        es[id] = e;
        id++;
    }
    E = id + 1;
    long long ans = kruskal();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10468
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e14;
const int ZERO = 0;
const int MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

signed main() {
    int A,B,C;
    cin >> A >> B >> C;
    if(A + B + C >= 22) {
        cout << "bust" << endl;
    }
    else {
        cout << "win" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
using namespace std;
int dh[3] = { -1, 0, 1 };
int dw[3] = { -1, 0, 1 };

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

    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            if (s[i][j] == '.')
            {
                int cnt = 0;
                for (int x = 0; x < 3; ++x)
                {
                    for (int y = 0; y < 3; ++y)
                    {
                        if (x == 1 && y == 1) continue;
                        int ni = i + dh[x];
                        int nj = j + dw[y];
                        if (ni < 0 || ni >= h || nj < 0 || nj >= w)
                            continue;
                        
                        if (s[ni][nj] == '#')
                            ++cnt;
                    }
                }
                s[i][j] = '0' + cnt;
            }
        }
    }

    for (int i = 0; i < h; ++i)
    {
        cout << s[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>
#include<string.h>
#include<ctype.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
    int n,k;
	int a[100005];
    scanf("%d%d",&n,&k);
  	    for(int i=0;i<n;i++)
   	    {
        	scanf("%d",&a[i]);
	    }	
    	sort(a,a+n);	
    	int min=999999999;
    	int cha=0;
    	for(int i=0;i<=n-k;i++)
    	{
    		cha=a[i+k-1]-a[i];
    		if(cha<min)
 		    min=cha;
	}	
   	printf("%d\n",min);    
	return 0;
}

Measured memory_bytes: 640
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from functools import reduce
from operator import mul
from collections import Counter
import itertools

num = stdin.readline().rstrip()
if '7' in num:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 68220
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
// numeric_limits<int>::max()

int main()
{
    ll N;
    cin >> N;
    vector<ll> V(N), C(N);
    for (int i = 0; (i < N); ++i) {
        cin >> V[i];
    }
    for (int i = 0; (i < N); ++i) {
        cin >> C[i];
    }
    ll sum = 0;
    for (int i = 0; (i < N); ++i) {
        if (V[i] - C[i] > 0)
            sum += V[i] - C[i];
    }
    cout << sum << endl;
    return 0;
}


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

signed main(){
	int N, i, j, k, ans = 0;
	scanf("%lld", &N);
	string S;
	cin >> S;
	vector<int> A(N + 1, -1);
	for(i = 0; i < N; i++){
		if(S[i] == 'R'){
			A[i + 1] = 0;
		}
		if(S[i] == 'G'){
			A[i + 1] = 1;
		}
		if(S[i] == 'B'){
			A[i + 1] = 2;
		}
	}
	vector<vector<int>> count(N + 1, vector<int>(3, 0));
	for(i = 1; i <= N; i++){
		for(j = 0; j < 3; j++){
			count[i][j] = count[i - 1][j];
		}
		count[i][A[i]]++;
	}
	for(j = 1; j <= N; j++){
		for(k = j + 1; k <= N; k++){
			if(A[j] == A[k]){
				continue;
			}
			int Ai = 2 * (A[j] + A[k]) % 3;
			ans += count[j - 1][Ai];
			if(j - (k - j) > 0 && A[j - (k - j)] == Ai){
				ans--;
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3972
//#include<cstdio>
//#include<cassert>
//#include<iostream>
//#include<cstring>
//#include<algorithm>
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define MAX ((int)1e6 + 5)
#define MAXL ((ll)1e18 + 5)
#define MAX_X ((ll)1e5 + 2)
#define pi (2.0*acos(0))
#define M ((int)1e6 + 7)
#define MOD ((int)1e9 + 7)
#define NN ((int)62500 + 7)
#define N ((int)2e5 + 5)
#define eps (0)
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL)
#define logn 29
#define endl "\n"
#define mp make_pair
#define BUCK 105
#define LEF (idx<<1)
#define RIG ((idx<<1)|1)
//#define int ll


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;

/*fast io
ios_base::sync_with_stdio(false);
cin.tie(NULL);
*/




typedef tree < int,  null_type,  less < int >,  rb_tree_tag,  tree_order_statistics_node_update > o_set;
//typedef tree < pair < int, int >,  null_type,  less < pair < int, int > >,  rb_tree_tag,  tree_order_statistics_node_update > o_set;
/// o_set s;
/// s.order_of_key(k) : Number of items strictly smaller than k .
/// *(s.find_by_order(k)) : K-th element in a set (counting from zero).

int arr[100];

int main()
{
    fastio;
    int n;
    cin>>n;
    for(int i = 1 ; i<=n ; i++) cin>>arr[i];
    ll tot = 1000;
    for(int i = 1 ; i<=n ; i++){
        if(arr[i]<arr[i+1]){
            ll stc = tot/arr[i];
            tot = tot%arr[i];
            tot += stc*arr[i+1];
        }
    }
    cout<<tot<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

/*bool subseq(string s,string t){
    ll y=0;
    for(ll i=0;y<s.size()&& i<t.size();i++){
        if(s[y]==t[i]){
            y++;
        }
    }
        if(y==s.size())
            return true;
        else  return false;
}*/
/*ll x=1000000001;
vector<bool>p(x,false);
void prime(){
    p[2]=true;
    for(ll i=3;i<x;i=i+2)
        p[i]=true;
    for(ll i=0;i<x;i=i+2){
        if(p[i]){
            for(ll j=i*i;j<x;j=j+i)
                p[j]=false;
        }
    }
}*/
/*vector<ll> divisor(ll n){
    vector<ll> d;
    for(ll i=1;i<=sqrt(n);i++){
        if(n%i==0){
        d.push_back(i);
        d.push_back(n/i);
        }
    }
    sort(d.begin(),d.end(),greater<ll>());
    return d;
}*/
/*bool bs(ll n,string s){
    ll a[4]={0};
    for(ll i=0;i<n-1;i++){
        a[s[i]-'0']++;
    }
    for(ll i=n-1;i<s.size();i++){
        a[s[i]-'0']++;
        if(a[1]>0 && a[2]>0 && a[3]>0)
        return true;
        a[s[i-n+1]-'0']--;
    }
    return false;
}*/


/*ll binarySearch(ll n,ll a[],ll x){
    ll low=0,high=n-1,mid,ans=-1;
    while(low<=high){
        mid=low+(high-low)/2;
        if(a[mid]>=x){

            high=mid-1;
        }
        else{
                ans=mid;
            low=mid+1;
        }
    }
    return a[ans];
}*/




/*bool subseq(string s,string t){
    ll y=0;
    for(ll i=0;y<s.size()&& i<t.size();i++){
        if(s[y]==t[i]){
            y++;
        }
    }
        if(y==s.size())
            return true;
        else  return false;
}*/
/*ll x=1000000001;
vector<bool>p(x,false);
void prime(){
    p[2]=true;
    for(ll i=3;i<x;i=i+2)
        p[i]=true;
    for(ll i=0;i<x;i=i+2){
        if(p[i]){
            for(ll j=i*i;j<x;j=j+i)
                p[j]=false;
        }
    }
}*/
/*vector<ll> divisor(ll n){
    vector<ll> d;
    for(ll i=1;i<=sqrt(n);i++){
        if(n%i==0){
        d.push_back(i);
        d.push_back(n/i);
        }
    }
    sort(d.begin(),d.end(),greater<ll>());
    return d;
}*/
/*bool bs(ll n,string s){
    ll a[4]={0};
    for(ll i=0;i<n-1;i++){
        a[s[i]-'0']++;
    }
    for(ll i=n-1;i<s.size();i++){
        a[s[i]-'0']++;
        if(a[1]>0 && a[2]>0 && a[3]>0)
        return true;
        a[s[i-n+1]-'0']--;
    }
    return false;
}*/


/*ll binarySearch(ll n,ll a[],ll x){
    ll low=0,high=n-1,mid,ans=-1;
    while(low<=high){
        mid=low+(high-low)/2;
        if(a[mid]>=x){

            high=mid-1;
        }
        else{
                ans=mid;
            low=mid+1;
        }
    }
    return a[ans];
}*/

string solve(ll n){


}

int main() {
    ll n,k;
    cin>>n;
    string a="abcdefghijklmnopqrstuvwxyz";
    string s;
    while(n>0){
        n=n-1;
        s=s+a[n%26];
        n=n/26;
    }
    for(ll i=s.size()-1;i>=0;i--)
        cout<<s[i];

}


Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;
int total=0,t=0,maxn=0,l=1;
int n,h,a;
int b[100010];
int main()
{
	cin>>n>>h;
	for(int i=1;i<=n;i++)
	{
		cin>>a>>b[i];
		maxn=max(a,maxn);
	}
	sort(b+1,b+n+1);
	l=n;
	while(1)
	{
		if(h<=0)break;
		if(b[l]>maxn)
		{
			t++;
			h-=b[l];
			l--;
		}
		else break;
	}
	//cout<<t<<endl;
	if(h<=0)cout<<t<<endl;
	else
	{
		t+=h/maxn;
		h%=maxn;
		if(h!=0)cout<<t+1;
		else cout<<t;
	}
	return 0;
}
//224 46 276

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#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 each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(ll, N, K, R, S, P);
  VAR(string, T);
  map<char, ll> score;
  map<char, char> win;
  win['r'] = 'p';
  win['s'] = 'r';
  win['p'] = 's';
  score['r'] = R;
  score['s'] = S;
  score['p'] = P;
  vector<char> v;
  ll ans = 0;
  rep(i, 0, N) {
    char vi = win[T[i]];
    if (i >= K && vi == v[i - K]) {
      vi = 'x';
    } else {
      ans += score[vi];
    }
    v.push_back(vi);
  }
  print(ans);
}


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

using namespace std;

struct team {
	int id, ac, pena;
	int wa[16];
	team(int id, int prob) : id(id), ac(0), pena(0){
		for (int i = 0; i < 16; i++){
			wa[i] = 0;
		}
	}

	void correct(int time, int prob){
		ac++;
		pena += (time + (20 * wa[prob]));
	}
	void uncorrect(int prob){
		wa[prob]++;
	}

	bool operator<(const team& a) const
	{
		if (ac == a.ac){
			if (pena == a.pena) return id > a.id;
			else return pena < a.pena;
		}
		else return ac > a.ac;
	}
	bool operator==(const team& a) const
	{
		return (ac == a.ac) && (pena == a.pena);
	}
};

int main(void)
{
	int M, T, P, R;

	while (cin >> M >> T >> P >> R, T){
		// wa[team][problem];
		int m, t, p, j;
		vector <team> data;
		for (int i = 0; i < T; i++){
			data.push_back(team(i + 1, P));
		}

		for (int i = 0; i < R; i++){
			cin >> m >> t >> p >> j;
			if (j != 0) {
				data[t - 1].uncorrect(p);
			}
			else {
				data[t - 1].correct(m, p);
			}
		}
		sort(data.begin(), data.end());

		for (int i = 0; i < T; i++){
			if (i == 0) {
				cout << data[i].id;
				continue;
			}
			if (data[i - 1] == data[i]) cout << "=";
			else cout << ",";
			cout << data[i].id;
		}
		cout << endl;
	}
	return 0;
}

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

int main() {
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  if(a1 + a2 + a3 <= 21){
    cout << "win" << endl;
  }else{
    cout << "bust" << endl;
    }
  return 0;
}

Measured memory_bytes: 256
import sys, re
from math import ceil, floor, sqrt, pi, factorial#, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    n = i_input()
    t, a = i_map()
    num_list = i_list()

    abs_num = INF
    ans = 0

    for i in range(n):
        tmp = t - num_list[i] * 0.006
        if abs(a-tmp) < abs_num:
            abs_num = abs(a-tmp)
            ans = i + 1

    print(ans)

if __name__ == '__main__':
    main()


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

#define all(x) (x).begin(),(x).end()

#define MOD 1000000007

using namespace std;

int main(){
	int n;
	bool ans = true;
	
	cin >> n;
	
	int h[n];
	
	for(int i=0; i<n; i++)	cin >> h[i];
	
	if(n==1){
		cout << "Yes" << endl;
	}else{
		for(int i=n-1; i>=1; i--){
			if(h[i-1]-h[i]>1){
				ans=false;
			}
			if(h[i-1]-h[i]==1){
				h[i-1]--;
			}
		}
		
		cout << (ans ? "Yes" : "No") << endl;
	}
	
	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000002486618624LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int H, W;


bool check(const std::map<char, int>& map)
{
  int a;

  if (H % 2 == 0 && W % 2 == 0) {
    a = H * W;
  }
  else if (H % 2 && W % 2) {
    a = H * W - (H + W) + 1;
  }
  else if (H % 2) {
    a = H * W - W;
  }
  else {
    assert(W % 2 && H % 2 == 0);

    a = H * W - H;
  }

  assert(a % 4 == 0);

  std::priority_queue<int> pq;

  for (const auto& kv : map)
    pq.push(kv.second);

  for (int i = 0; i < a / 4; i ++) {
    int x = pq.top(); pq.pop();

    if (x < 4)
      return false;

    x -= 4;

    if (x)
      pq.push(x);
  }

  int ce = 0, co = 0;

  while (! pq.empty()) {
    int x = pq.top(); pq.pop();

    (x % 2 == 0 ? ce : co) ++;
  }

  if (H % 2 == 0 && W % 2 == 0) {
    return co == 0;
  }
  else if (H % 2 && W % 2) {
    return co == 1;
  }
  else {
    return co == 0;
  }
}

int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  std::cin >> H >> W;

  std::vector<std::string> A(H);

  std::map<char, int> map;

  for (auto& s : A) {
    std::cin >> s;

    for (const auto& c : s)
      map[c] ++;
  }

  std::cout << (check(map) ? "Yes" : "No") << std::endl;
  
  return 0;
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

int solve() {
	int N; cin >> N;
	vector<int>A(N + 1); rep(i, 0, N + 1) { cin >> A[i]; }
	if (N > 0 and A[0] != 0)return -1;

	int sum = accumulate(all(A), 0ll) - 1;
	int a = 1;
	int ans = 1;
	rep(i, 0, A.size()) {
		ans += A[i] * i;
		a -= A[i];
		if (a < 0)return -1;
		dump(a, ans, sum);
		int d = min(a, sum);
		a += d;
		sum -= d;
		ans -= d * i;
	}
	dump(a, ans, sum);
	if (a != 0)return -1;
	return ans;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	cout << solve() << endl;

	return 0;
}


Measured memory_bytes: 3988
#include<iostream>
    using namespace std;
     
    int main()
    {
      int a,b,c,x,i,j,k;
      cin >> a >> b >> c >> x;
      int count = 0;
      int total;
      for(i = 0; i <= a; i++)
      {
        for(j = 0; j <= b; j++)
        {
          for(k = 0; k <= c; k++)
          {
            total = 500 * i + 100 * j + 50 * k;
            if(total == x)
            {
              count++;
            }
          }
        }
      }
      cout << count << endl;
      return 0;
    }

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

int main() {
	int N, count = 0;
	long x;
	long a[105];
	cin >> N >> x;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}

	long tmp;
	for (int i = 0; i < N - 1; ++i) {
		for (int j = i + 1; j < N; ++j) {
			if (a[i] > a[j]) {
				tmp = a[j];
				a[j] = a[i];
				a[i] = tmp;
			}
		}
	}

	for (int i = 0; i < N; i++) {
		x -= a[i];
		count++;
		if (x < 0) break;
	}
	count--;
	if (x == 0) count++;

	cout << count << endl;


}

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

int main(){
  string s;
  cin >> s;
  string t = s;
  reverse(s.begin(),s.end());
  string sb = s.substr(0,(s.size()-1)/2);
  string tb = sb;
  reverse(sb.begin(),sb.end());
  string se = s.substr((s.size()+1)/2,s.size()-1);
  string te = se;
  reverse(se.begin(),se.end());
  if(s==t && sb==tb && se==te) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main()
{
	int k,n,m;
	cin>>k>>n>>m;
	for(int i=n;i<=m;i++)
	{
		if(i%k==0)
		{
			cout<<"OK"<<endl;
			return 0;
		}
	}
	cout<<"NG"<<endl;
	return 0;
} 


Measured memory_bytes: 3636
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int a = sc.nextInt();
      int b = sc.nextInt();
      char[] c = sc.next().toCharArray();
      int cntA = 0;
      int cntB = 0;
      for(int i = 0;i < n;i++){
      	if(c[i]=='a'&&cntA+cntB<a+b){
        	System.out.println("Yes");
            cntA++;
        }else if(c[i]=='b'&&cntA+cntB<a+b&&cntB<b){
        	System.out.println("Yes");
            cntB++;
        }else System.out.println("No");
      }
    }
}


Measured memory_bytes: 36740
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

void solve(char str[81]);


int main(void){
  char str[81];
  while(fgets(str,81,stdin)!=NULL){
    solve(str);
  }
  return 0;
}

void solve(char str[81]){
  double stack[100];
  char *p;
  int i=0;
  for(p = strtok(str," \n");p != NULL;p = strtok(NULL," \n")){
    if(strlen(p)==1){
      if(*p == '+'){
        stack[i-2] = stack[i-2] + stack[i-1];
        stack[i] = 0;
        i--;
      }else if(*p == '-'){
        stack[i-2] = stack[i-2] - stack[i-1];
        stack[i] = 0;
        i--;
    }else if(*p == '*'){
      stack[i-2] = stack[i-2] * stack[i-1];
      stack[i] = 0;
      i--;
    }else if(*p == '/'){
      stack[i-2] = stack[i-2] / stack[i-1];
      stack[i] = 0;
      i--;
    }else{
      stack[i]=atoi(p);
      //printf("%f\n",stack[i]);
      i++;
    }
  }else{
    stack[i] = atoi(p);
    //printf("%f\n",stack[i]);
    i++;
  }
}
  printf("%f\n",stack[0]);
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

void code() {
    int h,w,k;
    cin>>h>>w>>k;
    int ans=0;
    vector<string> A(h);
    for(int i=0; i<h; i++) {
        cin>>A[i];
    }
    vector<int> R(h);
    vector<int> C(w);
    for(int i=0; i<h; i++) {
        R[i] = count(A[i].begin(), A[i].end(), '#');
    }
    for(int i=0; i<h; i++) {
        for(int j=0; j<w; j++) {
            C[j]+=((A[i][j]=='#')?1:0);
        }
    }
    sort(R.begin(), R.end());
    sort(C.begin(), C.end());

    for(int i=0; i<(1<<h); i++) {
        for(int j=0; j<(1<<w); j++) {
            int r=i, c=j, x=0, y=0;
            vector<string> check(A.begin(), A.end());
            while(r!=0) {
                if(r&1==1) {
                    for(int ii=0;ii<w;ii++){
                        if(A[x][ii]=='#')
                            check[x][ii]='.';
                    }
                }
                x++;
                r>>=1;
            }
            while(c!=0) {
                if(c&1==1) {
                    for(int ii=0;ii<h;ii++){
                        if(A[ii][y]=='#')
                            check[ii][y]='.';
                    }
                }
                y++;
                c>>=1;
            }
            int bb=0;
            int cnt=0;
            for(int i=0; i<h; i++) {
                cnt+=(count(check[i].begin(), check[i].end(), '#'));
            }
            if(cnt==k)
                ans++;
        }
    }

    cout << ans << "\n";
}

signed main() {
    std::ios_base::sync_with_stdio(false);
    int t=1;
    // cin>>t;
    for(int i=0; i<t; i++) {
        code();
    }
}


Measured memory_bytes: 3656
#include <stdio.h>

int main(void) {
    int H, W;

    while (1) {
        scanf("%d %d", &H, &W);

        if (H == 0 && W == 0) break;

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (i == 0 || i == H - 1) {
                    printf("#");
                } else {
                    if (0 < j && j < W - 1)printf(".");
                    else printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    
    return 0;
}


Measured memory_bytes: 2064
#include<cstdio>
#include<iostream>
#include<fstream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define Set(a) memset(a,0,sizeof(a))
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define openf(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define re register
#define ri re int
#define il inline
typedef long long ll;
typedef unsigned long long ull;
template<typename T> inline T rd(T& x)
{
	T f=1;x=0;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(T)(c-'0');
	x*=f;
	return x;
}
ll rd(){ll x;rd(x);return x;}
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
const int inf=1<<30;

ll ans=0;int n;
int main()
{
	cin>>n;
	F(i,1,n) if(i%3!=0&&i%5!=0) ans+=i;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3596
program main
  implicit none
  character(100000) :: s
  character(1) :: c
  integer :: n, i, res, r
  read (*, *) s
  n = len_trim(s)
  res = 0
  do i = 1, n
    write (c, "(i1)") mod(i, 2)
    if (s(i:i) == c) res = res + 1
  end do
  r = 0
  do i = 1, n
    write (c, "(i1)") mod(i + 1, 2)
    if (s(i:i) == c) r = r + 1
  end do
  res = min(res, r)
  write (*, "(i0)") res
end program main


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

using namespace std;

int main() {
	int a;
	int b;
	cin >> a >> b;
	if (a == 1 && b == 1) cout << 1 << endl;
	else if (a == 1) cout << b - 2 << endl;
	else if (b == 1) cout << a - 2 << endl;
	else cout << (unsigned long long int) (a - 2) * (b - 2) << endl;
	return 0;
}


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

#define INF 2147483647
#define RMQ_SIZE 262144

using namespace std;

void update(int pos, int value);
int getMin(int right, int left);
int dfs(int a,int b,int k,int l,int r);

int tree[RMQ_SIZE];

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

    for (int i = 0; i <= n; i++) {
        update(i, INF);
    }
    for (int i = 0; i < q; i++) {
        int tmp, a, b;
        cin >> tmp >> a >> b;
        if (tmp) {
            cout << getMin(a, b+1) << endl;
        } else {
            update(a, b);
        }
    }
            
    return 0;
}


int dfs(int a,int b,int k,int l,int r)
{
    //* ????±????????????????????????¬???????????¢?´¢.
    if (r <= a || b <= l) {
        return INF;
    }
    //* ??¨?????¬?????????????±?????????\???????????????.
    if (a <= l && r <= b) {
        return tree[k];
    }
    int m = (l+r)/2;
    return min(dfs(a, b, k*2+1, l, m), dfs(a, b, k*2+2, m, r));
}

int getMin(int right, int left)
{
    return dfs(right, left, 0, 0, RMQ_SIZE/2);
}

void update(int pos, int value)
{
    pos += (RMQ_SIZE/2 -1);
    tree[pos] = value;
    while (pos) {
        pos = (pos-1)/2;
        tree[pos] = min(tree[pos*2+1], tree[pos*2+2]);
    }
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;

vector<int> ans(105,0);

bool check(int s, int g, int b, int c){
  int count=0;
  for(int j=s; j<=g; j++){
    if(ans.at(j)<=b+count) count++;
  }
  if(count==c) return true;
  else return false;
}

int main(){
  int n;
  cin >> n;
  vector<int> b(n);
  rep(i,n) cin >> b.at(i);

  vector<int> c(n);
  rep(i,n) c.at(i) = (i+1) - b.at(i);

  vector<int> placed(n,1);
  rep(i,n){
    int max_b=0;
    int max_i=0;
    rep(j,n){
      if(c.at(j)<=i){
        //cout << check(n-i,n-1,b.at(j),c.at(j)) << endl;
        if(max_b<=b.at(j)&&placed.at(j)&&check(n-i,n-1,b.at(j),c.at(j))){
          max_b=b.at(j);
          max_i=j;
        }
      }
    }
    placed.at(max_i) = 0;
    ans.at(n-i-1) = max_b;
  }
  
  rep(i,n) if(ans.at(i)==0){cout << -1; return 0;}
  rep(i,n) cout << ans.at(i) << endl;  
}

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> d(k);
  vector<int> s(n,0);
  for(int i=0;i<k;i++){
    cin >> d.at(i);
    for(int j=0;j<d.at(i);j++){
      vector<int> a(d.at(i));
      cin >> a.at(j);
      s.at(a.at(j)-1)=1;
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    ans+=s.at(i);
  }
  cout << n-ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	int n, m, c;
	cin >> n >> m >> c;
	vector <vector<int>> ar(n, vector<int>(m, 0));
	vector <int> b(m);
	for(int &x: b) cin >> x;
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++)
			cin >> ar[i][j];
	}

	int res = 0;
	for(int i=0; i<n; i++){
		int cur = 0;
		for(int j=0; j<m; j++){
			cur += ar[i][j] * b[j];
		}
		cur += c;
		if(cur > 0)
			res++;
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 256
from logging import *
basicConfig(level=DEBUG, format='%(levelname)s: %(message)s')
disable(CRITICAL)

n = int(input())
X = input()
debug('n {}'.format(n))
debug('X {}'.format(X))
po = X.count('1')

# if po == 0:
#     print(0)
#     exit()

pp = po + 1
pm = max(1, po - 1)

rp = 0
rm = 0
for x in X:
    rp = (rp*2 + int(x)) % pp
    rm = (rm*2 + int(x)) % pm

bp = [0]*(n) # 2^i % (po+1)
bm = [0]*(n) # 2^i % (po-1)
bp[n-1] = 1 % pp
bm[n-1] = 1 % pm
for i in range(n-1,0,-1):
    bp[i-1] = bp[i]*2 % pp
    bm[i-1] = bm[i]*2 % pm

debug('po {}'.format(po))
debug('pp {}'.format(pp))
debug('pm {}'.format(pm))
debug('rp {}'.format(rp))
debug('rm {}'.format(rm))
debug('bp {}'.format(bp))
debug('bm {}'.format(bm))
debug('===')

def popcount(x):
    c = 0
    while x > 0:
        if x & 1: c += 1
        x //= 2
    return c

def f(x):
    if x==0: return 0
    return f(x % popcount(x)) + 1

for i in range(n):
    if X[i] == '0':
        ri = (rp + bp[i]) % pp
    else: # '1'
        if po-1 != 0: ri = (rm - bm[i]) % pm
        else:
            print(0)
            continue
    debug('i {} ri {}'.format(i,ri))
    c = f(ri) + 1
    debug('c {}'.format(c))
    print(c)



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

int main(){

    int N, M;
    cin >> N >> M;
    priority_queue<pair<int, int>> q;
    for(int i = 0; i < N; i++){ 
         int A;
         cin >> A;
         q.push(make_pair(A,1));
    }
    for(int i = 0; i < M; i++){ 
         int B, C;
         cin >> B >> C;
         q.push(make_pair(C, B));
    }

    long long ans = 0;
    for(int i = 0; i < N; i++){ 
         pair<int, int> P = q.top();
         q.pop();
         ans += P.first;
         if(P.second > 1){
             P.second--;
             q.push(P);
         }
    }

cout << ans << endl; 
}

Measured memory_bytes: 2420
S = list(input().strip())

odd = ['R', 'U', 'D']
even = ['L', 'U', 'D']

ans = 'Yes'
for i in range(len(S)):
    if i % 2 == 1:
        if S[i] in even:
            pass
        else:
            ans = 'No'
            break
    else:
        if S[i] in odd:
            pass
        else:
            ans = 'No'
            break

print(ans)            

Measured memory_bytes: 3060
#include<stdio.h>

int main(){

int time,h = 0,m = 0,s = 0;

scanf("%d",&time);

while(time >= 3600){
time -= 3600;
h++;
}

while(time >= 60){
time -= 60;
m++;
}

s = time;

printf("%d:%d:%d\n",h,m,s);

return 0;
}


Measured memory_bytes: 2112
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

enum next = [
    "Sunny": "Cloudy",
    "Cloudy": "Rainy",
    "Rainy": "Sunny"
];

void main()
{
    writeln(next[readln.chomp]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
int k;
int main() {
    DAU
    cin >> k;
    while (k--)
        cout << "ACL";
    PLEC
}


Measured memory_bytes: 3612
M,N = gets.split.map(&:to_i)
A,B = [],[]
M.times{ A << gets.chomp.split('') }
N.times{ B << gets.chomp.split('') }

(M-N+1).times do |i|
  (M-N+1).times do |j|
    flg = true
    N.times do |ii|
      if flg
        N.times do |jj|
          if A[i+ii][j+jj] != B[ii][jj]
            flg = false
            break
          end
        end
      end
    end
    if flg
      puts "Yes"
      exit
    end
  end
end

puts "No"

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

int n;
long long arr[405];
long long pref[405];
long long memo[405][405];

long long dp(int x,int y){
	if(x>=y)return 0;
	if(memo[x][y]!=-1)return memo[x][y];
	long long ans=9000000000000000010;
	for(int i=x;i<y;i++){
		ans=min(ans,dp(x,i)+dp(i+1,y));
	}
	return memo[x][y]=ans+pref[y]-pref[x-1];
}

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


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//end



int main(){
   int n; scanf("%d",&n);
   string s,t; cin>>s>>t;
   rrep(_,n,-1){
      bool f=1;
      rep(i,0,_)if(t[i]!=s[i+(n-_)]){f=0; break;}
      if(f){
         printf("%d\n",2*n-_);
         return 0;
      }
   }
   return 0;
}

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

int main() {
    int N;
    scanf("%d", &N);

    long long *L = (long long *) malloc(sizeof(long long) * N);
    L[0] = 2;
    L[1] = 1;

    for (int i = 2; i <= N; i++) {
        long long tmp_sum = 0;
        for (int j = i - 2; j < i; j++) {
            tmp_sum += L[j];
        }
        L[i] = tmp_sum;
    }

    printf("%lld\n", L[N]);
    return 0;
}

Measured memory_bytes: 128
fn input() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_string()
}

fn main() {
    let line = &input();
    let seg: Vec<f64> = line
        .split_whitespace()
        .map(|s| s.parse::<f64>().unwrap())
        .collect();
    circle(seg);
}

fn circle(v: Vec<f64>) {
    println!(
        "{} {}",
        v[0].powf(2.0) * std::f64::consts::PI,
        2.0 * v[0] * std::f64::consts::PI
    );
}


Measured memory_bytes: 5056
// B - 美しい文字列 / Beautiful Strings https://atcoder.jp/contests/abc044/tasks/abc044_b

  import io.Source
  import scala.collection.mutable

  object Main extends App {
    val xs = Source.stdin.getLines().foreach { w =>
      println(solve(w))
    }

    def solve(w: String): String = {
      val map = mutable.Map.empty[Char, Int]
      w.foreach { ch =>
        if (map.contains(ch)) {
          val c = map(ch)
          map(ch) = c + 1
        } else {
          map(ch) = 1
        }
      }
      if (map.forall { case (ch, c) => c % 2 == 0 })
        "Yes"
      else
        "No"
    }
  }


Measured memory_bytes: 25548