akhauriyash/Code-Regression huggingface dataset:
// Beginner160.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <bits/stdc++.h>
#include <iostream>

using  namespace std;
typedef long long ll;

int main()
{
	/*string s;
	cin >> s;
	cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << '\n';*/

	int x;
	cin >> x;

	int y500 = x / 500;
	x -= y500 * 500;
	int y5 = x / 5;

	ll resut = y500 * 1000 + y5 * 5;

	cout << resut  << '\n';
	
}



Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! get_char {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().chars().collect::<Vec<_>>()
        }
    };
}

fn main() {
    let (d, g) = get!(usize, i64);
    let pc_arr = get!(i64, i64; d);

    let pc_arr = pc_arr
        .into_iter()
        .enumerate()
        .map(|(i, (num, bonus))| ((i as i64 + 1) * 100, num, bonus))
        .collect::<Vec<_>>();

    let mut ans = i64::max_value();
    for bit in 0..(1 << d) {
        let mut total = 0;
        let mut count = 0;
        let mut ri = None;
        for (i, (point, num, bonus)) in pc_arr.clone().into_iter().enumerate() {
            if bit & (1 << i) != 0 {
                total += point * num + bonus;
                count += num;
            } else {
                ri = Some((point, num));
            }
        }

        if total < g {
            let remain = g - total;
            match ri {
                None => continue,
                Some((point, num)) => {
                    let n = (remain + point - 1) / point;
                    if n <= num {
                        count += n;
                    } else {
                        continue;
                    }
                }
            }
        }
        ans = std::cmp::min(ans, count);
        continue;

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


Measured memory_bytes: 4352
package main

import (
	"fmt"
	"sort"
)

type AB struct {
	price int
	max   int
}

type ABs []AB

func (a ABs) Len() int {
	return len(a)
}

func (a ABs) Less(i, j int) bool {
	return a[i].price < a[j].price
}

func (a ABs) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	abs := make([]AB, n)
	for i := range abs {
		fmt.Scan(&abs[i].price)
		fmt.Scan(&abs[i].max)
	}

	sort.Sort(ABs(abs))
	ans := 0
	for i := range abs {
		if m-abs[i].max > 0 {
			ans += abs[i].price * abs[i].max
			m -= abs[i].max
		} else {
			ans += abs[i].price * (m)
			break
		}
	}
	fmt.Println(ans)
}


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

class Bit{
private:
  ll* tree;
  ll size;
  
public:
  Bit(ll n){
    for(int i = 0; i < 6; i++){
      n |= (n >> (1 << i));
    }
    size = n + 1;
    
    tree = new long long[size + 1];
    for(ll i = 0; i < size + 1; i++)
      tree[i] = 0;
  }

  void add(ll x, ll v){
    while(x <= size){
      tree[x] += v;
      x += (x & -x);
    }
  }

  ll sum(ll x){
    ll ret = 0;
    while(x > 0){
      ret += tree[x];
      x -= (x & -x);
    }
    return ret;
  }

};

int main(){
  ll n, q;
  cin >> n >> q;
  Bit bit(n);
  
  for(ll i = 0; i < q; i++){
    int com;
    ll x ,y;
    cin >> com >> x >> y;
    if(com == 1){
      cout << bit.sum(y) - bit.sum(x - 1ll) << endl;
    }else{
      bit.add(x, y);
    }
  }


}

Measured memory_bytes: 4132
#include<bits/stdc++.h>
#define a(x)begin(x),end(x)
using namespace std;int f,Q,T,F;string S;deque<char>q;main(){for(cin>>S>>Q,q={a(S)};Q--&&cin>>T;)if(T&1)f^=1;else cin>>F>>S,F-1^f?q.push_back(S[0]):q.push_front(S[0]);S={a(q)};if(f)reverse(a(S));cout<<S;}

Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int main(){
	int n,q;
	while(cin>>n>>q,n){
		int data[101]={0},ans=0,max=0;
		for(int i=0;i<n;i++){
			int a,b;
			cin>>a;
			for(int j=0;j<a;j++){
				cin>>b;
				data[b]++;
			}
		}
		for(int i=1;i<=100;i++){
			if(data[i]>=q&&data[i]>max){
				ans=i;
				max=data[i];
			}
		}
		
		cout<<ans<<endl;
	}
	/*
	for(int n,q;cin>>n>>q,n;){
		int data[101]={0},ans=0,max=0;
		
		for(int i,x,y;i<n;i++){
			for(cin>>x;x>0;x--){
				cin>>y;
				data[y]++;
			}
		}
		
		for(int i=1;i<=100;i++){
			if(data[i]>=q&&data[i]>max){
				ans=i;
				max=data[i];
			}
		}
		
		cout<<ans<<endl;
	}
	*/
	return 0;
}


Measured memory_bytes: 1160
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	if N%10 == (N / 100) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1840
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val Array(h, w) = sc.nextLine.split(" ").map(_.toInt)
    val rectangle = List.fill(h)(sc.nextLine)
    (1 to 2 * h).map{
      ind => rectangle((ind - 1)/2)
    }.foreach(println)
  }
}


Measured memory_bytes: 27456
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    int k, x;
    cin >> k >> x;
    for(int i = x - k + 1; i <= x + k - 1; i++){
        cout << i << " ";
    }
    cout << endl;
    solve();
    return 0;
}



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

x,y,z,k = map(int,input().split())

A = sorted(map(int,input().split()))[::-1]
B = sorted(map(int,input().split()))[::-1]
C = sorted(map(int,input().split()))[::-1]

AB = sorted([a+b for a in A for b in B])[::-1]

ans = sorted([ab + c for ab in AB[:k] for c in C])[::-1]

for i in ans[:k]:
    print(i)



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

const int maxn = 2e5+100;
typedef long long LL;

const LL mod = 1e9+7;

LL fac[maxn];

LL pow_mod(LL a,LL p)
{
    LL res = 1;
    while(p)
    {
        if(p&1) res = res*a%mod;
        a = a*a%mod;
        p >>= 1;
    }
    return res;
}


LL GetC(LL n,LL m) //预处理版本　fac[0] = 1;
{
    if(n < m) return 0;
    if(m > n-m) m = n-m;
    return fac[n]*pow_mod(fac[n-m]*fac[m]%mod,mod-2)%mod;
}


LL cal(int r1,int c1,int r2,int c2)
{
    LL sum = r2-r1 + c2-c1;
    return GetC(sum,r2-r1);
}

int R,C;
int A,B;

int main()
{
    fac[0] = 1;
    for(int i = 1;i < maxn;++i)
        fac[i] = fac[i-1]*i%mod;

  //  freopen("./test.txt","r",stdin);
    scanf("%d %d %d %d",&R,&C,&A,&B);

    LL sum = cal(1,1,R,C);
    for(int i = 1;i <= B;++i)
    {
        LL t = cal(1,1,R-A,i)*cal(R-A+1,i,R,C)%mod;
        sum = (sum - t + mod)%mod;
    }

    printf("%lld\n",sum);

    return 0;
}


Measured memory_bytes: 1792
/**
 * Dictionary
 */

#include <iostream>
#include <unordered_set>

using namespace std;

int main() {

    int n;
    cin >> n;

    unordered_set<string> dic;

    for (int i = 0; i < n; i++) {
        string c, s;
        cin >> c >> s;
        switch (c[0]) {
            case 'i':
                dic.insert(s);
                break;
            case 'f':
                if (dic.find(s) != dic.end())
                    cout << "yes" << endl;
                else
                    cout << "no" << endl;
        }
    }
}


Measured memory_bytes: 31868
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)

int X, Y, A, B, C;
ll p[100005], q[100005], r[100005];
ll sump[100005]={}, sumq[100005]={}, sumr[100005]={};

ll solve(int c){
	// 赤リンゴの使用個数を増やした方がいい？
	int ok = -1;
	int ng = X;
	while(ng-ok>1){
		int m = (ok+ng)/2;
		int a = m;
		int b = X+Y-a-c;
		if(a >= X) ng = m;
		else if(b <= 0) ng = m;
		else if(b > Y) ok = m;
		else if(sump[a]+sumq[b] < sump[a+1]+sumq[b-1]) ok = m;
		else ng = m;
	}
	int a = ng;
	return sump[a] + sumq[X+Y-a-c];
}
signed main(){
	cin >> X >> Y >> A >> B >> C;
	rep(i, A) cin >> p[i];
	rep(i, B) cin >> q[i];
	rep(i, C) cin >> r[i];
	sort(p, p+A, greater<int>());
	sort(q, q+B, greater<int>());
	sort(r, r+C, greater<int>());
	rep(i, A) sump[i+1] = sump[i] + p[i];
	rep(i, B) sumq[i+1] = sumq[i] + q[i];
	rep(i, C) sumr[i+1] = sumr[i] + r[i];

	ll ans = 0;
	rep(i, C+1){ //無色のりんごを使う個数
		if(i > X+Y) break;
		ans = max(ans, sumr[i]+solve(i));
	}
	cout << ans << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rem(i, s, n) for (int i = (s); i >= (n); --i)
using ll = long long;
const int MOD = 1e9 + 7;
const int MAX = 1e5;

int main(){
    int n, k, R, S, P;
    string t;
    cin >> n >> k >> R >> S >> P >> t;

    ll ans = 0;
    rep(i, 0, n){
        if (k <= i && i + k < n && t[i] == t[i - k]) {
            if (t[i + k] == 'r') t[i] = 'p';
            else if (t[i + k] == 's') t[i] = 'r';
            else t[i] = 's';
        }
        else if (k <= i && t[i] == t[i - k]) continue;
        else if (t[i] == 'r') ans += P;
        else if (t[i] == 's') ans += R;
        else if (t[i] == 'p') ans += S;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
<?php
$a=explode(' ',trim(fgets(STDIN)));
if(($a[2]-$a[4]>=0)&($a[3]-$a[4]>=0)&($a[2]+$a[4]<=$a[0])&($a[3]+$a[4]<=$a[1])){echo 'Yes';}
else{echo 'No';}
?>

Measured memory_bytes: 15432
# -*- coding: utf-8 -*-
# モジュールのインポート
import statistics


def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    N = int(input())
    A = list(map(int, input().split()))

    return N, A


def main(N: int, A: list) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 整数列の長さ(1 <= N <= 2 × 10^5)
        A (list): 整数列(1 <= A_i <= 10^9)
    """
    # 求解処理
    B = [A[i] - (i + 1) for i in range(N)]
    b = statistics.median_high(B)
    ans = sum([abs(B[i] - b) for i in range(N)])

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N, A = get_input()

    # メイン処理
    main(N, A)


Measured memory_bytes: 35416
import sys
t='X'
for e in sys.stdin:
 for i in'0123456789'[(e[0]==t)*(e[1]!='+')or('+X'in e)*('+X='not in e)or(e[-2:]=='=X'):]:
  l,r=e.replace(t,i).split('=')
  if sum(map(int,l.split('+')))==int(r):print(i);break
 else:print('NA')


Measured memory_bytes: 5616
/* #                          */

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <deque>
#include <map>
#include <iomanip>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cstring>
//#pragma warning(disable:4996)

using namespace std;


/** Type Define **/
typedef long long int           ll;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<string>          vs;
typedef vector<bool>            vb;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;
#define		it(x)  x.begin() 
#define		all(x)  x.begin(), x.end()
#define		pb(x)   push_back(x)
constexpr int           inf = 0x3f3f3f3f;
constexpr long long 	INF = 9123456789123456789;
constexpr long long     MOD = 1000000007LL;
/*************************************************/
int N, M;

void sol() {

}

int main() {
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cin.tie(nullptr);
    cin >> N >> M;
    vi num(N, -1);
    bool chk(false);

    for (int i = 0; i < M; i++) {
        int s, c; cin >> s >> c;
        s--;
        if(num[s] >= 0)
            if (num[s] != c) { cout << "-1\n"; return 0; }
        num[s] = c;
    }
    if (num[0] == 0 && N > 1) {
        cout << "-1\n"; return 0;
    }
    if (num[0] == -1 && N > 1) num[0] = 1;

    string s;
    for (int i = 0; i < N; i++) {
        if (num[i] == -1) s += '0';
        else s += ( '0' + num[i]);
    }
    cout << s << endl;


    return 0;
}

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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > Matrix;



int main() {
	int a, b, c;

	cin >> a >> b >> c;

	cout << min(a + b, min(b + c, a + c));

	return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lli k;
    cin>>k;
    lli i,j,flag=0;
    vector<lli> v;
    
    for(i=1;i<10;i++)
    v.push_back(i);
    
    for(i=0;v.size()<100000;i++)
    {
        lli cur=v[i]%10;
        for(j=cur-1;j<=cur+1;j++)
        {
            if(j>=0 && j<=9)
            {
                v.push_back(v[i]*10+j);
            }
        }
    }
    
    cout<<v[k-1];
    return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

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

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

void compute() {

}

int main() {
  string s;
  cin >> s;
  int sp = 0;
  vector<int> ans((int)s.size(),0);
  int prevL = -1;
  rep(i,(int)s.size()) {
    if( s[i] == 'L' ) {
      if( i-1>=0 && s[i-1] == 'L' ) {
	int len = i - prevL;
	if( len & 1 ) {
	  ans[prevL-1]++;
	} else {
	  ans[prevL]++;
	}
      } else {
	int len = i - sp + 1;
	if( len & 1 ) {
	  ans[i]   += ( len / 2 + 1 );
	  ans[i-1] += ( len - ans[i] );
	} else {
	  ans[i] += (len/2);
	  ans[i-1] += (len / 2);
	}
      }
      sp = i + 1;
    }
    if( i > 0 && ( s[i] == 'L' && s[i-1] == 'R' ) ) prevL = i;
    //cout << "???(" << s[i] << ")" << endl;
    //rep(j,(int)s.size()) cout << ans[j] << " "; puts("");
  }
  rep(i,(int)s.size()) {
    if( i ) printf(" ");
    cout << ans[i];
  } puts("");
  compute();
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h> 
#include<cmath>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define x first
#define y second
#define nax 3e5+2
using namespace std;

int main() 
{ 	
	ll ans=0;
	ll n;
	cin>>n;
	ans += (n/500)*1000;
	n = n%500;
	ans += (n/5)*5;
	cout<<ans;
	
	return 0;
} 


Measured memory_bytes: 768
#pragma GCC optimize("O3")

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

# include <stdio.h>
# include <bits/stdc++.h>


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace __gnu_pbds;
using namespace std;
 
typedef
tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g;
int ans, res;
int cur;

int main () {
	SpeedForce;
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i], g.pb(a[i]);
	sort(every(g));
	for (int d = 1; d <= 1e5; d ++) {
		cur = g.end() - lower_bound(every(g), d);
		if (cur * 2 == n) ans ++;
	}
	cout << ans;
	return Accepted;
}

// B...a

Measured memory_bytes: 3196
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r:rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

func main() {
	sc := NewScanner()
	S := sc.NextLine()
	N := sc.NextInt()

	s := make([]int, len(S))
	for i := 0; i < len(S); i++ {
		s[i] = int(S[i] - 'a')
	}
	for i := 0; i < len(s) - 1; i++ {
		if s[i] == 0 {
			continue
		}
		if 26 - s[i] <= N {
			N -= 26 - s[i]
			s[i] = 0
		}
	}
	p := len(s) - 1

	N %= 26
	s[p] += N
	s[p] %= 26
	for i := 0; i < len(s); i++ {
		fmt.Print(string(s[i] + 'a'))
	}
	fmt.Println()

}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
 
  if (c == 'a') {
    cout << "vowel" << endl;
  }
  else if (c == 'i') {
    cout << "vowel" << endl;
  }
  else if (c == 'u') {
    cout << "vowel" << endl;
  }
  else if (c == 'e') {
    cout << "vowel" << endl;
  }
  else if (c == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) x.begin(), x.end()
#define pb  push_back
#define mb  make_pair
#define fi  first
#define se  second

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
const ll mod = 1000000007;

void solve()
{
    int n;
    cin >> n;
    int d = n % 10;
    if(d == 2 || d == 4 || d == 5 || d == 7 || d == 9){
        cout << "hon";
    }
    else if(d == 3){
        cout << "bon";
    }
    else
    {
        cout << "pon";
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    //int t; cin >> t; while(t--)
    solve();
	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll, ll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rev(a) reverse(all(a)
#define ld long double
const ll mod=1e9+7;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
bool ispal(string s){
    int n=s.length();
    for(int i=0; i<n/2; i++){
        if(s[i]!=s[n-1-i]) return false;
    }
    return true;
}
int main() {
    string s;
    cin >> s;
    int n=s.length();
    string s1=s.substr(0,n/2);
    string s2=s.substr((n+1)/2,n/2);
    if(ispal(s)&&ispal(s1)&&ispal(s2)) puts("Yes");
    else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <iomanip>

using namespace std;

int main()
{
    string s;

    cin >> s;
    if(s == "ABC")
    {
        cout << "ARC" << endl;
    }
    else
    {
        cout << "ABC" << endl;
    }

    return 0;
}

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

int main(){
	int n;
	set<ll> s;
	cin >> n;
	for(int i = 0; i < n; ++i){
		ll a;
		cin >> a;
		if(s.count(a) == 1){
			s.erase(a);
		}
		else{
			s.insert(a);
		}
	}
	cout << s.size() << endl;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
 }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
ll dp[1005][1005];
int main(){
  string a,b;
  cin>>a>>b;
  memset(dp,0,sizeof(dp));
  ll ans=0;
  rep(i,sz(a)){
    dp[i+1][0]=i+1;
  }
  rep(i,sz(b)){
    dp[0][i+1]=i+1;
  }
  rep(i,sz(a))rep(j,sz(b)){
    ll cost=(a[i]==b[j])? 0:1;
    dp[i+1][j+1]=min(dp[i][j]+cost,min(dp[i][j+1]+1,dp[i+1][j]+1));
  }
  COUT(dp[sz(a)][sz(b)]);
}


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

int abs(int a, int b){
  if(a > b) return a - b;
  else return b - a;
}

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
      cin >> vec.at(i);
  }
  vector<int> dp(N);
  for(int i = 1; i < N; i++){
    dp.at(i) = dp.at(i-1) + abs(vec.at(i-1), vec.at(i));
    if(i != 1) dp.at(i) = min(dp.at(i), dp.at(i-2) + abs(vec.at(i-2), vec.at(i)));
  }
  cout << dp.at(N-1) << endl;
}

Measured memory_bytes: 1024
n = input()
n_list = list(n)
l = len(n_list)
for i in range(l):
    if n_list[i] == "1":
        n_list[i] = "9"
    else:
        n_list[i] = "1"

result = ""
for i in range(l):
    result = result+n_list[i]

print(result)




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

int main() {
  int N;
  cin>>N;
  	if(N==1||N==2||N==3||N==5||N==6||N==9||N==10||N==13||N==14||N==17){
      cout<<"No"<<endl;    
    }
  	else{
      cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int a[4]={0},b[4]={0},town[4]={0},ans=0;
    for(int i=0;i<4;i++){
        scanf("%d %d",&a[i],&b[i]);
        if(a[i]==1) town[0]++;
        if(a[i]==2) town[1]++;
        if(a[i]==3) town[2]++;
        if(a[i]==4) town[3]++;
        if(b[i]==1) town[0]++;
        if(b[i]==2) town[1]++;
        if(b[i]==3) town[2]++;
        if(b[i]==4) town[3]++;
    }

    if(town[0]%2==1) ans++;
    if(town[1]%2==1) ans++;
    if(town[2]%2==1) ans++;
    if(town[3]%2==1) ans++;
    
    if(ans==0||ans==2) printf("YES");
    else printf("NO");
    
    

    return 0;
}

Measured memory_bytes: 128
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int l; cin >> l;
    // vector<int> as(l); cin >> as;
    // zero even odd even zerp
    vector<vector<ll>> dp(5, vector<ll>(l + 1));
    for(int i = 1; i <= l; i++){
        ll a; cin >> a;
        ll mini = dp[0][i - 1];
        dp[0][i] = mini + a;
        mini = min(mini, dp[1][i - 1]);
        dp[1][i] = mini + (a & 1) + (a == 0) * 2;
        mini = min(mini, dp[2][i - 1]);
        dp[2][i] = mini + !(a & 1);
        mini = min(mini, dp[3][i - 1]);
        dp[3][i] = mini + (a & 1) + (a == 0) * 2;
        mini = min(mini, dp[4][i - 1]);
        dp[4][i] = mini + a;
    }
    printde(dp);
    cout << min({dp[0][l], dp[1][l], dp[2][l], dp[3][l], dp[4][l]}) << '\n';
}


Measured memory_bytes: 9752
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    string s; cin >> s;

    bool ng = false;
    int k = 0; rep (i, m) k += (s[i] == '1');
    rep (i, m, n + 1) {
        k += (s[i] == '1') - (s[i - m] == '1');
        if (k == m) ng |= true;
    }
    if (ng) {
        cout << -1 << "\n";
        return 0;
    }

    vector<int> dist;
    int now = n;
    while (now > 0) {
        reprev (i, 1, min(now, m) + 1) {
            if (s[now - i] == '0') {
                now -= i;
                dist.push_back(i);
                break;
            }
        }
    }
    reverse(all(dist));
    for (int i : dist) cout << i << " "; cout << "\n";
    return 0;
}

Measured memory_bytes: 1096
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

const int maxn=2000;

char g[maxn+1][maxn+1];
int tate[maxn][maxn]={0};
int yoko[maxn][maxn]={0};

int ans=0;

int main(){
    
    int h,w;
    cin >> h>>w;
    
    rep(i,h){
        rep(j,w){
            cin >> g[i][j];
        }
    }
    
    rep(i,h){
        int cnt=0;
        int pre=0;
        rep(j,w){
            if(g[i][j]=='.'){
                cnt++;
            }else{
                for(int k=pre;k<j;k++){
                    yoko[i][k]=cnt;
                }
                pre = j+1;
                cnt=0;
            }
        }
        for(int k=pre;k<w;k++){
            yoko[i][k]=cnt;
        }
    }
    
    rep(i,w){
        int cnt=0;
        int pre=0;
        rep(j,h){
            if(g[j][i]=='.'){
                cnt++;
            }else{
                for(int k=pre;k<j;k++){
                    tate[k][i]=cnt;
                }
                pre = j+1;
                cnt=0;
            }
        }
        for(int k=pre;k<h;k++){
            tate[k][i]=cnt;
        }
    }
    
//    rep(i,h){
//        rep(j,w){
//            cout << yoko[i][j]<<' ';
//        }
//        cout << endl;
//    }
    
    rep(i,h){
        rep(j,w){
            ans=max(tate[i][j]+yoko[i][j]-1,ans);
        }
    }
    
    cout << ans<<endl;
    
    return 0;
}


Measured memory_bytes: 35456
#include<cstdio>
#include<cstring>
using namespace std;
struct sd{
	int son[26],endby[26],v,f,end;
}t[1000005];
int n,m;
long long ans;
bool add[27];
char s[1000005];
inline void insert(int now,int nlen,int val) {
	t[now].v=val;
	if(!nlen) t[now].end++;
	else {
		if(t[now].son[s[nlen]-'a']) {t[t[now].son[s[nlen]-'a']].f=now;insert(t[now].son[s[nlen]-'a'],nlen-1,s[nlen]-'a');}
		else {++m;t[now].son[s[nlen]-'a']=m;t[m].f=now;insert(m,nlen-1,s[nlen]-'a');}
	}
	for(int i=0;i!=26;++i) if(add[i]) t[now].endby[i]++;
	add[val]=true;
	return;
}
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {
		scanf("%s",s+1);
		memset(add,0,sizeof(add));
		insert(0,strlen(s+1),26);
		for(int j=strlen(s+1);j;--j) s[j]=NULL;
	}
	for(int i=1;i<=m;++i)
		ans+=(long long)t[i].end*(t[t[i].f].endby[t[i].v]-1LL);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 245228
from itertools import combinations
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    CMB = list(combinations(A, 3))
    ans = 0
    for (i, j, k) in CMB:
        if i==j or i==k or j==k:
            continue
        x = sorted([i,j,k])
        if (sum(x[:2])) > x[-1]:
            ans += 1
    print(ans)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 20528
program main
  integer::n,i,j,k,ans
  !integer,allocatable::
  character(3)::day
read(*,*)day
select case(day)
case('SUN')
  ans=7
case('MON')
  ans=6
case('TUE')
  ans=5
case('WED')
  ans=4
case('THU')
  ans=3
case('FRI')
  ans=2
case('SAT')
  ans=1
end select

write(*,*) ans
end program


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

using namespace std;
using ll=long long;

int main()
{
    int n,W;cin >>n>>W;
    ll dp[n+1][W+1];
    int w[n];ll v[n];
    for(int i=0;i<n;i++){
        cin >>w[i]>>v[i];
    }
    for(int i=0;i<=n;i++){
        for(int j=0;j<=W;j++){
            dp[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<=W;j++){
            if(j-w[i]>=0)dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i+1][j]);
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
        }
    }
    cout <<dp[n][W]<< endl;
    return 0;
}


Measured memory_bytes: 79104
Var a:Array[1 .. 26] of Longint;
    Ok:Boolean;
    S:String;
    i:Longint;
Begin
    Readln(S); OK:=True;
    Fillchar(a,sizeof(a),0);
    For i:=1 to length(S) do inc(a[ord(S[i])-96]);
    For i:=1 to 26 do 
        If odd(a[i]) then begin
            OK:=False;
            Break;
        End;
    If OK then writeln('Yes') else writeln('No');
End.

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<bool>prime(55556,true);
  prime[0]=false;prime[1]=false;
  for(int i=2;i<=55555;i++){
    if(prime[i]){
      for(int j=2;i*j<=55555;j++)prime[i*j]=false;
      if(i%5==1&&N>0){cout<<i<<" ";N--;}
    }
  }
}

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

string s;
std::vector<string> v;



int main(){
  int i,j,K;

  std::cin >> s;
  std::cin >> K;
  for(i=0;i<s.size();i++){
    for(j=1;j<6;j++){
      v.push_back(s.substr(i,j));

    }
  }
sort(v.begin(),v.end());
unique(v.begin(),v.end());

std::cout << v[K-1] << '\n';





return 0;

}


Measured memory_bytes: 1660
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

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

    if ((int)n % 2 == 0) {
        cout << 0.5f << endl;
    } else {
        cout << setprecision(6) << (floor(n/2.0f) + 1.0f) / n << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int fa[100001],fl,fr,d[100001],n,m,l,r,d2;
bool j;
int gf(int x)
{
	int d1=fa[x];
	if(x==fa[x])return x;
	fa[x]=gf(fa[x]);
	d[x]+=d[d1];
	return fa[x];
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	fa[i]=i;
	while(m)
	{
		scanf("%d%d%d",&l,&r,&d2);
		fl=gf(l);fr=gf(r);
		if(fl==fr&&d[r]-d[l]!=d2)
		{
			j=1;break;
		}
		else 
		{
			fa[fr]=fl;d[fr]=d2-d[r]+d[l];
		}
		m--;
	}
	if(j)printf("No");
	else printf("Yes");
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<lint> vlint;

#define inf 1e+9
#define endl "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define rep_rev(i, n) for (int i = n-1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()

#define pb push_back
#define eb emplace_back
#define Size(c) (int)(c).size()

#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))

template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

template <class T, class S> inline bool chmax(T &a, S b) {
    if(a < b) {a = b;return 1;} return 0;
}
template <class T, class S> inline bool chmin(T &a, S b) {
    if(a > b) {a = b;return 1;} return 0;
}
template <class T>
void line(vector<T> &x){for (auto&& xi : x) cin >> xi;}

inline void IN(void){ return;}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){ cin >> first; IN(rest...); return;}

#define INT(...) int __VA_ARGS__; IN (__VA_ARGS__)
#define LINT(...) lint __VA_ARGS__; IN (__VA_ARGS__)
#define STR(...) string __VA_ARGS__; IN(__VA_ARGS__)

template <class T> void UNIQUE(vector<T> &x) {
    sort(all(x)); x.erase(unique(all(x)), x.end());
}
template <class T> void print_vec(T first, T end){
    for (auto i = first; i < end - 1; i++) cout << *i << " ";
    cout << *(end-1) << endl;
}

template<class... T>
void debug_print(T... args){
    vector<lint> tmp = initializer_list<lint>{args...};
    print_vec(all(tmp));
}
template<class T>
void print(T a){ cout << a << endl;}

vector<string> Yes = {"No", "Yes"};
vector<string> YES = {"NO", "YES"};

int ord(char x){ return (int)(x - 'a');}
char chr(lint x){ return (char)(x + (lint)('a'));}
lint mod = 1e9+7;
// lint mod = 

lint sum(vlint a){lint ret = 0; for(auto&& v:a) ret += v; return ret;}
lint vmini(vlint a, lint &index){
    lint ret = LLONG_MAX;
    rep(i, Size(a)){ if (chmin(ret, a[i])) index = i;}
    return ret;
}
lint vmaxi(vlint a, lint &index){
    lint ret = -LLONG_MAX;
    rep(i, Size(a)){ if (chmax(ret, a[i])) index = i;}
    return ret;
}

lint vmin(vlint a){
    lint ret = LLONG_MAX; for (auto && v : a) chmin(ret, v); return ret;
}
lint vmax(vlint a){
    lint ret = -LLONG_MAX; for (auto && v : a) chmax(ret, v); return ret;
}


vlint base_3(int k){
    vlint ret;
    while (k > 0){
        ret.pb(k % 3);
        k /= 3;
    }
    reverse(all(ret));
    return ret;
}

lint dist(lint x, lint y){
    return x*x + y*y;
};
int main(){
    LINT(k);
    lint ans = 1;
    lint ret = 7 % k;
    map<int, int> cnt;
    while (ret != 0){
        ret *= 10; ret %= k;
        ret += 7; ret %= k;
        if (cnt[ret] == 1){
            ans = -1; break;
        }
        cnt[ret]++;
        ans ++;
    }
    print(ans);
}


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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (max(x-a, a-x) < max(x-b, b-x)) cout << "A\n";
  else cout << "B\n";
  return 0;
}


Measured memory_bytes: 256
INPUT_SENTENCES = 2
ss = [input() for i in range(INPUT_SENTENCES)]
N = int(ss[0].split(" ")[0])
X = int(ss[0].split(" ")[1])
L = [int(i) for i in ss[1].split(" ")]
D = [0]
for i in range(1, N + 1):
    D.append(D[i-1] + L[i-1])
print(len([i for i in D if i <= X]))

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    int H, W;
    while(true){
        cin >> 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 || j==0 || i==H-1 || j==W-1){
                    cout << "#";
                }
                else{
                    cout << ".";
                }
            }
            cout << endl; 
        }
        cout << endl;
    }
}



Measured memory_bytes: 3096
#include <sys/time.h>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

using ll = long long;
using P = pair<int, int>;
using VP = pair<int, pair<int, int> > ;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
ll mod = 1000000007LL;

const int maxE = 200001;

int main() {
	vector<int> ps;

	for(int i = 2; i < 1001; i++) {
		bool is_prime = true;
		for(int p : ps) {
			if (i % p == 0) {
				is_prime = false;
				continue;
			}
		}
		if (is_prime) {
			ps.push_back(i);
		}
	}

	int n;
	cin >> n;
	int a[n];
	rep(i, n) {
		cin >> a[i];
	}
	vector count(1010, 0);
	map<int,int> count1000;

	rep(i, n) {
		int cur = a[i];
		for(int p: ps) {
			if (cur % p == 0) {
				count[p]++;
				cur /= p;

				while(cur % p == 0) {
					cur /= p;
				}
			}
			if (cur == 1) break;
		}
		if (cur > 1) {
			count1000[cur]++;
		}
	}

	bool is_all = false;
	bool is_one = true;

	rep(i, 1010) {
		/*
		if (i < 10) {
			cout << i << ":" << count[i] << endl;
		}
		*/
		if (count[i] == n) {
			is_all = true;
		}
		if (count[i] > 1) {
			is_one = false;
		}
	}

	for(auto cur : count1000) {
		if (cur.second == n) {
			is_all = true;
		}
		if (cur.second > 1) {
			is_one = false;
		}
	}

	if (is_all) {
		cout << "not coprime" << endl;
		
	} else if (is_one) {
		cout << "pairwise coprime" << endl;


	} else {
		cout << "setwise coprime" << endl;
	}

	return 0;
}


Measured memory_bytes: 10400
# Date [ 2020-09-08 00:04:04 ]
# Problem [ b.py ]
# Author Koki_tkg

import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

class BinaryIndexedTree:
    def __init__(self, n):
        '''1-index'''
        self.size = n + 1
        self.data = [0] * self.size
        self.element = [0] * self.size
        self.depth = 1 << n.bit_length() - 1
    
    def build(self, array):
        for i, x in enumerate(array):
            self.add(i, x)

    def add(self, i, v):
        self.element[i] += v; i += 1 # 1-index
        while i < self.size:
            self.data[i] += v
            i += i & -i
    
    def sum(self, i):
        ret = 0; i += 1 # 1-index
        while i > 0:
            ret += self.data[i]
            i -= i & -i
        return ret
    
    def query(self, l, r=None):
        '''get sum [l, r)'''
        if r == None: return self.element[l]
        return self.sum(r) - self.sum(l-1)

    def lower_bound(self, v):
        if v <= 0: return 0
        k = self.depth; i = 0
        while k > 0:
            if i+k < self.size and self.data[i+k] < v:
                v -= self.data[i+k]
                i += k
            k >>= 1
        return i + 1
    
    def upper_bound(self, v):
        if v <= 0: return 0
        k = self.depth; i = 0
        while k > 0:
            if i+k < self.size and self.data[i+k] <= v:
                v -= self.data[i+k]
                i += k
            k >>= 1
        return i + 1

def Main():
    n, q = read_ints()
    bit = BinaryIndexedTree(n)
    a = read_int_list()
    bit.build(a)
    for _ in range(q):
        t, l, r = read_ints()
        if t == 0:
            bit.add(l, r)
        else:
            print(bit.query(l, ~-r))    

if __name__ == '__main__':
    Main()

Measured memory_bytes: 83028
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    dunk((c/a) * b);
}
    

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		scan.useDelimiter(",|//s|\n");
		int w = Integer.parseInt(scan.next());
		int n = Integer.parseInt(scan.next());
		int[] number = new int[w];
		for( int i = 0; i < w; i++){
			number[i] = i+1;
		}
		for( int i = 0; i < n; i++ ){
			int a = Integer.parseInt(scan.next()) - 1;
			int b = Integer.parseInt(scan.next()) - 1;
			int temp = number[a];
			number[a] = number[b];
			number[b] = temp;
		}
		for( int i = 0; i < w; i++ ){
			System.out.println(number[i]);
		}
		return;
	}
}

Measured memory_bytes: 17152
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

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

	typedef pair<int, int> int_pair;
	vector<int_pair> a;

	while (true)
	{
		int H, W;
		cin >> H >> W;

		a.push_back(int_pair(H, W));

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

	for (int i = 0; a[i].first != 0 && a[i].second != 0; ++i)
	{
		for (int h = 0; h < a[i].first; ++h) {

			if (h == 0 || h == a[i].first - 1)
				for (int w = 0; w < a[i].second; ++w)
					cout << '#';
			else
				for (int w = 0; w < a[i].second; ++w)
					if (w == 0 || w == a[i].second - 1)
						cout << "#";
					else
						cout << ".";

			cout << endl;
		}

		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1196
# https://beta.atcoder.jp/contests/abc074/tasks/arc083_a
# C - Sugar Water
A, B, C, D, E, F = gets.chomp.split(" ").map(&:to_i)
# 100*A gの水
# 100*B gの水
# C gの砂糖
# D gの砂糖
# E g/100ml溶ける
# F gの最大質量
#print("A:#{A} B:#{B} C:#{C} D:#{D} E:#{E} F:#{F}\n")

# 溶ける場合の濃度を計算
def calc_concentration(water, sugar)
  if water != 0 && E*water/100 >= sugar
    100*sugar/(water+sugar).to_f
  end
end

# [[砂糖水の質量, 砂糖の質量, 濃度],[],...]
concentrations = []
#print("A:#{F/(100*A)}杯まで wB:#{(F)/(100*B)+1}杯まで sC:#{(F)/C+1}杯まで sD:#{(F)/D+1}杯まで\n")

# カップAで入れられる回数は F/100*A+1 回まで
(F/(100*A)+1).times do |water_a|
  # カップBで入れられる回数は (F-100*A*water_a)/100*B+1 回まで
  ((F-100*A*water_a)/(100*B)+1).times do |water_b|
    # カップCで入れられる回数は(F-100*A*water_a-100*B*water_b)/C+1 回まで
    ((F-100*A*water_a-100*B*water_b)/C+1).times do |sugar_c|
      # カップDで入れられる回数は (F-100*A*water_a-100*B*water_b-C*sugar_c)/D+1 回まで
      ((F-100*A*water_a-100*B*water_b-C*sugar_c)/D+1).times do |sugar_d|
        # print("wA:#{water_a} wB:#{water_b} sC:#{sugar_c} sD:#{sugar_d}\n")
        if !calc_concentration(100*A*water_a + 100*B*water_b, sugar_c*C+sugar_d*D).nil?

          concentrations << [water_a*A*100+water_b*B*100+sugar_c*C+sugar_d*D, sugar_c*C+sugar_d*D, calc_concentration(100*A*water_a + 100*B*water_b, sugar_c*C+sugar_d*D)]
        end
      end
    end
  end
end
#p concentrations
max_concentration = concentrations.max{|ary_a, ary_b| ary_a[2] <=> ary_b[2]}
print("#{max_concentration[0]} #{max_concentration[1]}")


Measured memory_bytes: 39164
import           Data.List (foldl')

main :: IO ()
main = do
  _ <- getLine
  as <- getLine
  let (_, a) = foldl'
        (\(over, acc) a
         -> let a' = read a :: Integer
                temp = a' * acc
            in if a' == 0
               then (False, 0)
               else if over
                    then (over, acc)
                    else if temp > u
                         then (True, -1)
                         else (False, temp))
        (False, 1)
        (words as)
      b = if a > u || a < 0
          then -1
          else a
      u = 10 ^ 18
  print b


Measured memory_bytes: 64140
#include <cstdio>
long long n, x, ans, a[200005];
int main() {
	int i, j;
	scanf("%lld", &n);
	for(i=0; i<n; i++) scanf("%lld", a+i);
	for(i=j=0; i<n; i++) {
		for(; j<n && !(x&a[j]); j++) x |= a[j];
		ans += j-i;
		x ^= a[i];
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 1664