akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')


def solve(A: int, B: int):
    for i in range(1000 + 1):
        if int(i * 0.08) == A and int(i * 0.1) == B:
            return i
    return -1


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    print(f'{solve(A, B)}')


if __name__ == '__main__':
    main()


Measured memory_bytes: 75224
N = int(input())
S = list(input())
cnt = 0
if N % 2 == 1:
    print("No")
else:
    for i in range(1,N//2 + 1):
        if S[i-1] != S[N//2 + i - 1]:
            cnt = 1
    if cnt == 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int main(){
    int n;
    int l,r,ans;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>l>>r;
        ans+=r-l+1;
    }
    cout<<ans<<endl;//输出结果
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>


using namespace std;

const int MAX	= 1e5 + 5;
const int LIM	= 3e5 + 5;
const int MOD	= 1e9 + 7;
const long double  EPS	= 1e-10;
const double PI = acos(-1.0);

typedef long long LL; 
typedef long double LD;


#define uint64 unsigned long long
#define int64 long long


#define IOS  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

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

int main()
{
    string a;
    string b;

    cin >> a >> b;

    string magic = a + b;
    int mahou = stoi(magic);

    for (int i = 0; i <= 1000 ; i++) {
        if (i*i == mahou) {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    
    return 0;
}




Measured memory_bytes: 3596
package main

import (
  "fmt"
  "math"
  "strconv"
)

func main() {
  var a, b int
  fmt.Scan(&a, &b)

  s := fmt.Sprintf("%d%d", a, b)
  v, err := strconv.ParseFloat(s, 64)
  if err == nil {
    f := math.Trunc(math.Sqrt(v))
    if f*f == v {
      fmt.Println("Yes")
    } else {
      fmt.Println("No")
    }
  } else {
    fmt.Println(err)
  }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  vector<ll> l(n+1, 1), r(n+1, 1);
  l[0] = 0; r[n] = 0;
  rep(i, n) l[i+1] = __gcd(l[i], a[i]);
  rep(i, n) r[n-1-i] = __gcd(r[n-i], a[n-1-i]);

  ll ans = 0;

  rep(i, n) {
    chmax(ans, __gcd(l[i], r[i+1]));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define LL long long
using namespace std ;
void Read ( LL &x, char c = getchar(), bool f = 0 ) {
	for ( x = 0 ; !isdigit(c) ; c = getchar() ) if (c == '-') f = 1 ;
	for ( ; isdigit(c) ; c = getchar() ) x = 10*x + c - '0' ;
	if (f) x = -x ;
}
LL n, k, a, b ;
LL Find ( LL x ) {
	LL l = 1, r = b-1, mid, rec = b ;
	while (l <= r) {
		mid = (l+r)>>1 ;
		if ((n-mid)/b <= x) rec = mid, r = mid-1 ;
		else l = mid+1 ;
	}
	return rec ;
}
int main() {
	LL ans = 0, t, r ;
	Read(n), Read(k) ;
	for ( b = k+1 ; b <= n ; b ++ ) {
		t = (n-k)/b ;
		r = Find(t-1) ;
		ans += (r-k)*(t+1) + (b-r)*t ;
	}
	if (k == 0) ans -= n ;
	cout << ans << endl ;
	return 0 ;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	int N, K;
	cin >> N >> K;

	vector<ll> Ai(N, 0);
	rep(i, N) cin >> Ai[i];

	ll ans = (ll)(1e12);
	for (int i = 0; i < pow(2, N); ++i) {

		ll c_height = Ai[0];
		ll up_cnt = 0;
		int bk_cnt = 1;
		for (int j = 1; j < N; ++j) {
			if ((i >> j & 1) == 1) {
				if (Ai[j] <= c_height) {
					c_height += 1;
					up_cnt = up_cnt + (c_height - Ai[j]);
				}
				else {
					c_height = Ai[j];
				}
				bk_cnt++;
			}
			else
			{
				c_height = max(c_height, Ai[j]);
			}
			

			if (bk_cnt == K) break;
		}

		if (bk_cnt == K) {
			ans = min(ans, up_cnt);
		}
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 4124
using System;

class Program
{
    static void Main()
    {
        string ABC = Console.ReadLine();
        string[] abc = ABC.Split(' ');

        if (abc[0] == abc[1] && abc[1] == abc[2])
        {
            Console.WriteLine("No");
        }
        else if (abc[0] != abc[1] && abc[1] != abc[2] && abc[0] != abc[2])
        {
            Console.WriteLine("No");
        }
        else
            Console.WriteLine("Yes");
    }
}

Measured memory_bytes: 17596
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
    int f= 0;
    string s;
    cin >> s;
    const char *x= s.c_str();
    for(int i=0; i<strlen(x); i++){
        if(x[i]=='+') f++;
        else f--;
    }
    cout << f << endl;
    return 0;
}

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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve()
{
  ll N;
  cin >> N;
  N--;
  ll ans = 0;
  if (N == 0)
    ans = 0;
  else
    ans = N * (N + 1) / 2;
  cout << ans << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	using ld=long double;
	int n; cin >> n;
	ld a = 1;
	vector<ld> v(n);
	REP(i, n) {
		cin >> v[i];
		a *= v[i];
	}
	ld b = 0;
	REP(i, n) {
		b += a / v[i];
	}
	cout << fixed << setprecision(12) << a / b << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
#include<bitset>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

int main(){
    int n, m, q;
    int a[50], b[50], c[50], d[50];
    int num[10];

    cin >> n >> m >> q;
    for (int i  = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }
    vector<int> v(n + m - 1, 1);
    for(int i = 0; i < m - 1; i++) v[i] = 0;
    int ans = 0;
    do {
        int point = 0;
        vector<int> A(50);
        int cnt = 0;
        int j = 0;
        for (int i = 0; i < n + m - 1; i++) {
            if (v[i] == 0) cnt++;
            else A[j++] = cnt + 1;
        }
        for (int i = 0; i < q; i++) {
            if (A[b[i]] - A[a[i]] == c[i])
                point += d[i];
        }
        ans = max(point, ans);
    } while (next_permutation(v.begin(), v.end()));
    cout << ans << endl;

    return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) ((v).begin(),(v).end())
#define COUT(x) cout<<(x)<<"\n"

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll num1 = n/(a+b);
    ll num2 = n%(a+b);
    COUT(num1*a+min(a,num2));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
  int D;
  ll G;
  cin >> D >> G;
  vector<ll> p(D),c(D);
  for(int i = 0; i < D; i++){
    cin >> p[i] >> c[i];
  }
  
  ll ans = 1<<29;
  for(int bit = 0; bit < (1<<D); bit++){
    ll temp = 0;
    ll n = 0;
    for(int i = 0; i < D; i++){
      if(bit & (1<<i)){
        temp += 100 * (i+1) * p[i] + c[i];
        n += p[i];
      }
    }
    if(temp >= G){
      ans = min(ans, n);
    }else{
      for(int i = D-1; i >= 0; i--){
        if(bit & (1<<i)) continue;
        for(int j = 0; j < p[i]; j++){
          if(temp >= G) break;
          temp += 100 * (i+1);
          n++;
        }
      }
      ans = min(ans, n);
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main() {
	string s;
	cin >> s;
	long r = 0, j = 0;
	for (int i = 0; i < s.length(); i++)
		if (s[i] == 'W')
			r += i - j++;
	cout << r << endl;
	return 0;
}


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

int main(){
    int a;
    cin >> a ;
    if(a==22) puts("Christmas Eve Eve Eve");
    if(a==23) puts("Christmas Eve Eve");
    if(a==24) puts("Christmas Eve");
    if(a==25) puts("Christmas");

    return 0;
}

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



using namespace std;
int n,m,taroSum,hanakoSum;

int hanako[102];
int taro[102];
void solve(){
  int sub = (hanakoSum - taroSum) ;
  if(sub == 0){
    int ans = 10000;
    for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      if(taro[i] == hanako[j] && ans > taro[i]) ans = taro[i];
    }}
    if(ans != 10000)cout << ans << " " << ans << endl;
    else cout << -1 << endl;
  }
  else {
    int minSum = 100000;
    int minH;
    int minT;
    for(int i = 0; i < n; i++){//taro
      for(int j = 0; j < m; j++){ //hanako
        if(sub - 2*hanako[j] + 2*taro[i]  == 0 && hanako[j] + taro[i] < minSum){
          minSum = taro[i] + hanako[j];
          minT = taro[i];
          minH = hanako[j];
        }
      }
    }
    if(minSum == 100000) cout << -1 << endl;
    else cout << minT << " " << minH << endl;
  }
}

int main(){

  while(true){
    cin >> n >> m;
    hanakoSum = 0;
    taroSum = 0;
    if(n == 0 && m == 0) break;
    for(int i = 0; i < n ; i++){
       cin >> taro[i];
       taroSum += taro[i];
    }

    for(int i = 0; i < m ; i++){
      cin >> hanako[i];
      hanakoSum += hanako[i];
    }
    solve();
  }

  return 0;
}



Measured memory_bytes: 3004
import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main(String... args) throws IOException {
        final int[] targetAry = load();

        insertionSort(targetAry);
    }

    public static int[] load() throws IOException {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int[] nums = new int[n];
        for (int i = 0; i < nums.length; i++) {
            nums[i] = scanner.nextInt();
        }

        return nums;
    }

    public static void insertionSort(final int[] targetAry) {
        for (int i = 0; i < targetAry.length; i++) {
            for (int j = i; 0 < j; j--) {
                if (targetAry[j - 1] > targetAry[j]) {
                    swap(targetAry, j - 1, j);
                }
                if ((1 < j) && (targetAry[j - 1] > targetAry[j - 2])) {
                    break;
                }
            }

            print(targetAry);
        }
    }

    public static void swap(final int[] targetAry, final int from, final int to) {
        final int tmp = targetAry[to];
        targetAry[to] = targetAry[from];
        targetAry[from] = tmp;
    }

    public static void print(final int[] targetAry) {
        final StringBuilder sb = new StringBuilder();
        for (int j = 0; j < targetAry.length; j++) {
            sb.append(targetAry[j]).append(j != targetAry.length - 1 ? ' ' : '\n');
        }
        System.out.print(sb.toString());
    }
}

Measured memory_bytes: 21680
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    
    vector<long long> A(X);
    vector<long long> B(Y);
    vector<long long> C(Z);
    vector<long long> AB;
    vector<long long> ABC;
    
    for (int i = 0; i < X; i++) cin >> A[i];
    for (int i = 0; i < Y; i++) cin >> B[i];
    for (int i = 0; i < Z; i++) cin >> C[i];
    
    for (int i = 0; i < X; i++){
        for (int j = 0; j < Y; j++){
            AB.push_back(A[i] + B[j]);   
        }
    }
    
    sort(AB.begin(), AB.end());
    reverse(AB.begin(), AB.end());
    
    for (int i = 0; i < min(K, (int)AB.size()); i++){
        for (int j = 0; j < Z; j++){
            ABC.push_back(AB[i] + C[j]);
        }
    }
    
    sort(ABC.begin(), ABC.end());
    reverse(ABC.begin(), ABC.end());
    
    for (int i = 0; i < K; i++){
        cout << ABC[i] << endl;
    }
}

Measured memory_bytes: 43368
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	string S;
	cin >> S;
	A--;
	B--;
	C--;
	D--;
	if (A > B) {
		swap(A, B);
		swap(C, D);
	}

	for (int i = B + 1;i < D;i++) {
		if (S[i - 1] == '#' && S[i] == '#') {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int i = A + 1;i < C;i++) {
		if (S[i - 1] == '#' && S[i] == '#') {
			cout << "No" << endl;
			return 0;
		}
	}
	if (C < D) {
		cout << "Yes" << endl;
		return 0;
	}
	if (C > D) {
		for (int i = B;i <= D;i++) {
			if (S[i] == '#') continue;
			if (S[i - 1] != '#' && S[i + 1] != '#') {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

template <typename T>
T powi(T a, ll n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= a; 
        a *= a;
        n >>= 1;
    }
    return ret;
}

template <ll mod>
class ModInt {
private:
    ll num;
public:
    ModInt() {};
    ModInt(ll n) { num = n % mod; }
    ModInt inv() const { return powi(*this, mod-2); }
    explicit operator ll() const { return num; }

    ModInt& operator+=(const ModInt& a) {
        num += a.num; 
        if (num >= mod) num -= mod; 
        return *this;
    }
    ModInt& operator-=(const ModInt& a) {
        if (num < a.num) num += mod;
        num -= a.num;
        return *this;
    }
    ModInt& operator*=(const ModInt& a) {
        num = num * a.num % mod;
        return *this;
    }
    ModInt& operator/=(const ModInt& a) { return *this *= a.inv(); }
    friend ModInt operator+(const ModInt& a, const ModInt& b) { return ModInt(a) += b; }
    friend ModInt operator-(const ModInt& a, const ModInt& b) { return ModInt(a) -= b; }
    friend ModInt operator*(const ModInt& a, const ModInt& b) { return ModInt(a) *= b; }
    friend ModInt operator/(const ModInt& a, const ModInt& b) { return ModInt(a) /= b; }

    friend ostream& operator<<(ostream& os, const ModInt& a) { return os << a.num; }
    friend istream& operator>>(istream& is, ModInt& a) {
        ll tmp;
        is >> tmp;
        a.num = tmp % mod;
        return is;
    }
};
using mint = ModInt<1000000007>;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (auto &e: a) cin >> e;

    struct st {
        mint c;
        mint cz;
        int pz;
        st(): c(0), cz(1), pz(0) {};
    };
    map<ll, st> m;
    ll z = 0;
    ll g = 0;
    for (int i = 0; i < n; ++i) {
        g ^= a[i];
        if (g == 0) {
            ++z;
            continue;
        }
        if (m[g].pz != z) {
            m[g].cz += m[g].c * (z - m[g].pz);
            m[g].pz = z;
        }
        m[g].c += m[g].cz;
    }

    mint ans;
    if (g == 0) {
        ans = powi((mint)2, z-1);
        for (auto &p: m) {
            ans += p.second.c;
        }
    } else {
        ans = m[g].cz;
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
  int N;
  string ans = "Three";
  cin >> N;
  
  for(int i=0; i<N; i++){
  	string S;
    cin >> S;
    
    if(S=="Y"){
    	ans = "Four";
    }
  }
  cout << ans << endl;
}


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

int main() {
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int tmp = 0;
	int ans = 0;

	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				tmp = 500 * i + 100 * j + 50 * k;
				if (tmp == x) {
					ans++;
					break;
				}
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
ll n2,ans;
int main(){
	cin>>s;
	ll lc=0;
	for(int i=0;i<(1<<s.size()-1);i++){
		lc=0;
		for(int j=0;j<s.size();j++){
			lc=lc*10+s[j]-'0';
			if(j<s.size()-1&&(i>>j&1)){
				ans+=lc;
				lc=0;
			}
		}
		ans+=lc;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner


object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val s = sc.next().toCharArray
    
    val rs = new Array[Int](n)
    val gs = new Array[Int](n)
    val bs = new Array[Int](n)
    
    for (i <- s.indices) {
      if (i > 0) {
        s(i) match {
          case 'R' =>
            rs(i) = rs(i - 1) + 1
            gs(i) = gs(i - 1)
            bs(i) = bs(i - 1)
          case 'G' =>
            rs(i) = rs(i - 1)
            gs(i) = gs(i - 1) + 1
            bs(i) = bs(i - 1)
          case 'B' =>
            rs(i) = rs(i - 1)
            gs(i) = gs(i - 1)
            bs(i) = bs(i - 1) + 1
        }
      } else {
        s(i) match {
          case 'R' =>
            rs(i) = 1
            gs(i) = 0
            bs(i) = 0
          case 'G' =>
            rs(i) = 0
            gs(i) = 1
            bs(i) = 0
          case 'B' =>
            rs(i) = 0
            gs(i) = 0
            bs(i) = 1
        }
      }
    }
    
    var ans = 0L
    
    for (i <- n - 1 to 2 by -1) {
      for (j <- i - 1 to 1 by -1) {
        if ((s(i) == 'R' && s(j) == 'G') || (s(i) == 'G' && s(j) == 'R')) {
          ans += bs(j)
          val m = i - j
          val n = j - m
          if (0 <= n && s(n) == 'B') {
            ans -= 1
          }
        } else if ((s(i) == 'R' && s(j) == 'B') || (s(i) == 'B' && s(j) == 'R')) {
          ans += gs(j)
          val m = i - j
          val n = j - m
          if (0 <= n && s(n) == 'G') {
            ans -= 1
          }
        } else if ((s(i) == 'B' && s(j) == 'G') || (s(i) == 'G' && s(j) == 'B')) {
          ans += rs(j)
          val m = i - j
          val n = j - m
          if (0 <= n && s(n) == 'R') {
            ans -= 1
          }
        }
      }
      
    }
    println(ans)
  }
  
  def printArray[T](arr: Array[T]): Unit = {
    for (i <- arr.indices) {
      print(s"${arr(i)} ")
    }
    println()
  }
}


Measured memory_bytes: 55456
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pld;
typedef pair<string, string> pss;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

inline ll input() {
    ll n;
    cin >> n;
    return n;
}

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

set_random;

const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n , k;

int main() {
    fast_io;

    cin >> n >> k;
    cout << n - k + 1 << endl;

    return 0;
}
/*
todo :
    1- set constants
    2- check TimeLimit and MemoryLimit
    3- check special test cases
    4- don't forget BS can help you that is good idea(use for loop for floats)
    5- don't forget printf and scanf can help you in your code speed
*/


Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

const LL MOD = 998244353;
LL combi(LL N_, LL C_) {
	const int NUM_ = 400001;
	static LL fact[NUM_ + 1], factr[NUM_ + 1], inv[NUM_ + 1];
	if (fact[0] == 0) {
		inv[1] = fact[0] = factr[0] = 1;
		for (int i = 2; i <= NUM_; ++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
		for (int i = 1; i <= NUM_; ++i) fact[i] = fact[i - 1] * i%MOD, factr[i] = factr[i - 1] * inv[i] % MOD;
	}
	if (C_<0 || C_>N_) return 0;
	return factr[C_] * fact[N_] % MOD*factr[N_ - C_] % MOD;
}
LL hcomb(int P_, int Q_) { return (P_ == 0 && Q_ == 0) ? 1 : combi(P_ + Q_ - 1, Q_); }

LL modpow(LL a, LL n = MOD - 2) {
	LL r = 1;
	while (n) r = r*((n % 2) ? a : 1) % MOD, a = a*a%MOD, n >>= 1;
	return r;
}

long long power(long long n, long long k, long long m) {
	if (k == 0) {
		return 1;
	}
	else if (k % 2 == 1) {
		return power(n, k - 1, m)*n%m;
	}
	else {
		long long t = power(n, k / 2, m);
		return t*t%m;
	}
}

int k, n;

int main() {
	cin >> k >> n;
	for (int i = 2; i <= 2 * k; i++) {
		int p = 0;
		for (int j = 1; j <= k; j++)if (j < i - j&&i - j <= k)p++;
		LL ret = 0;
		for (int q = 0; q <= min(p, n); q++) {
			if (i % 2 == 0) {
				ret += power(2, q, MOD)*combi(p, q) % MOD*(hcomb(k - 2 * p - 1 + q, n - q) + hcomb(k - 2 * p - 1 + q, n - q - 1)) % MOD;
			}
			else {
				ret += power(2, q, MOD)*combi(p, q) % MOD*hcomb(k - 2 * p + q, n - q) % MOD;
			}
		}
		cout << ret%MOD << endl;
	}
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	puta(n*n*3);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

static int
sum_digits(int n)
{
  int sum = 0;
  for (; n != 0; n /= 10)
  {
    sum += n % 10;
  }
  return sum;
}

static char const *
solve(int N)
{
  return N % sum_digits(N) == 0 ? "Yes" : "No";
}

int
main()
{
  int N;
  cin >> N;
  cout << solve(N) << endl;
  return 0;
}


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

#define F                   first
#define S                   second
#define int                 long long int
#define pb                  push_back
#define mp                  make_pair
#define pii                 pair<int,int>
#define vi                  vector<int>
#define mii                 map<int,int>
#define pqb                 priority_queue<int>
#define pqs                 priority_queue<int,vi,greater<int> >
#define mod                 1000000007
#define endl                '\n'
#define rep(i,a,b)            for(int i=a;i<b;i++)
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
    c_p_c();
    int n, k;
    cin >> n >> k;
    int a[n];
    rep(i, 0, n) {
        cin >> a[i];
    }
    vi dp(n + 1, INT_MAX);
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        int j = i - 1;
        while (j >= 0 and i - j - 1 < k) {
            dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
            j--;
        }
    }

    cout << dp[n - 1] << endl;

    return 0;
}

Measured memory_bytes: 4672
#include <stdio.h>

int main(void)
{
  int a, b, sum;
  scanf("%d %d",&a,&b);
  if(a>b)
    sum=a+(a-1);
  if (a<b)
    sum=b+(b-1);
  if (a==b)
    sum=a+b;
  printf("%d \n",sum);
  return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(S == T) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inp_ll;

const int MAXN = 100010;
const int INF = 1000000000;
const int MOD = 1000000007;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

int main()
{
	
	int n;
	ll ans = 0;
	cin >> n;
	for (int i = 1; i <= n; ++ i)
	{
		int x;
		cin >> x;
		ans += x-1;
	}
	cout << ans << endl;
	
	return 0;
}


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

typedef long long ll;
#define ALL(a) a, a+sizeof(a)/sizeof(a[0])
#define all(a) a.begin(),a.end()
#define MOD 1000000007
using namespace std;
ll gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n % m);
}
ll lcm(ll n, ll m) {return m / gcd(n, m) * n;}

int main(void) {
	ll w;
	cin >> w;
	cout << w * 32 << endl;
	return 0;
}


Measured memory_bytes: 3100
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	char[] s = sc.next().toCharArray();
      	int whereC = s.length+1;
      	for(int i = 0; i < s.length; i++){
        	if(s[i] == 'C') {
              whereC = i;
              break;
            }
        }
      	boolean isTrue = false;
      	for(int i = whereC; i < s.length; i++){
        	if(s[i] == 'F'){
              isTrue = true;
              break;
            }
        }
      	if(isTrue) System.out.println("Yes");
      	else System.out.println("No");
    }
}

Measured memory_bytes: 35632
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    while 1:
        n,m,a=MI()
        if (n,m,a)==(0,0,0):break
        to={}
        max_h=0
        for _ in range(m):
            h,p,q=MI()
            max_h=max(max_h,h)
            to[(h,p)]=q
            to[(h,q)]=p
        i=max_h+1
        j=a
        while i>0:
            i-=1
            if (i,j) in to:j=to[(i,j)]
        print(j)

main()


Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;

template <class T> using Vec = vector<T>;

/* 定数 */
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;

#define ALL(v) v.begin(), v.end()

#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    u32 R;
    cin >> R;
    cout << PI * 2.0 * R << endl;

}


Measured memory_bytes: 3796
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

pub struct Graph {
    graph: Vec<Vec<usize>>,
    v: usize,
}

type Edge = (usize, usize);
impl Graph {
    pub fn new_directed(edges: &[Edge], v: usize) -> Self {
        let mut graph = vec![Vec::new(); v];
        for &(u, v) in edges {
            graph[u].push(v);
        }
        Graph { graph, v }
    }

    pub fn solve(&self, mut indegreev: Vec<usize>) -> isize {
        let mut res = 0;
        let mut vv = Vec::new();
        for u in 0..self.v {
            if indegreev[u] == 0 {
                vv.push(u);
            }
        }
        loop {
            if vv.len() == 0 {
                break;
            }
            res += 1;
            vv = self.next(vv, &mut indegreev);
        }
        let is_ok = indegreev.into_iter().all(|x| x == 0);
        if is_ok {
            res as isize
        } else {
            -1
        }
    }

    fn next(&self, vv: Vec<usize>, indegreev: &mut Vec<usize>) -> Vec<usize> {
        let mut res = Vec::new();
        for u in vv {
            for &v in &self.graph[u] {
                indegreev[v] -= 1;
                if indegreev[v] == 0 {
                    res.push(v);
                }
            }
        }
        res
    }
}

fn solve() {
    input! {
        n: usize,
        matchv: [[Usize1; n - 1]; n]
    };

    let vn = n * (n - 1) / 2;
    let mut indegreev = vec![0; vn];
    let mut edges = Vec::new();
    let mut id_table: HashMap<(usize, usize), usize> = HashMap::new();
    let mut cur_id = 0;
    for i in 0..n {
        let a = i;
        for mv in matchv[i].windows(2) {
            let b = mv[0];
            let key = (a.min(b), a.max(b));
            let u = match id_table.get(&key) {
                Some(id) => *id,
                None => {
                    let id = cur_id;
                    id_table.insert(key, id);
                    cur_id += 1;
                    id
                }
            };
            let c = mv[1];
            let key = (a.min(c), a.max(c));
            let v = match id_table.get(&key) {
                Some(id) => *id,
                None => {
                    let id = cur_id;
                    id_table.insert(key, id);
                    cur_id += 1;
                    id
                }
            };
            indegreev[v] += 1;
            edges.push((u, v));
        }
    }

    let graph = Graph::new_directed(&edges, vn);
    let res = graph.solve(indegreev);
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 84948
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n,m,x = na()
a = na()

cost0 = 0
for i in range(1,x):
    if i in a:
        cost0 += 1

cost1 = 0
for i in range(x+1, n):
    if i in a:
        cost1 += 1

print(min(cost0,cost1))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using ll = long long;
const ll MOD=1e9+7;
const long long INF = 1LL<<60;

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

    rep(i,int(s.size())){
        cout << "x";
    }
    cout << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

ll max_diff(ll a, ll b, ll c, ll d) {
    if (a < 1 || b < 1 || c < 1 || d < 1)
        return INF;
    ll maxi = max({a, b, c, d});
    ll mini = min({a, b, c, d});
    return maxi - mini;
}

int main() {
    int n;
    cin >> n;
    vl a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vl suma(n + 1, 0);
    for (int i = 0; i < n; ++i) {
        suma[i + 1] += suma[i] + a[i];
    }
    ll ret = INF;
    for (int i = 1; i < n - 1; ++i) {
        auto bit = upper_bound(suma.begin(), suma.end(), (suma[i]) / 2);
        auto dit = upper_bound(suma.begin(), suma.end(), suma[i] + (suma[n] - suma[i]) / 2);
        for (auto &b : {bit, prev(bit), next(bit)}) {
            for (auto &d : {dit, prev(dit), next(dit)}) {
                chmin(ret, max_diff(*b, suma[i] - *b, *d - suma[i], suma[n] - *d));
            }
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,q;
  cin>>n>>k>>q;
  vector<int> a(q);
  for(int i=0;i<q;i++){
    cin>>a[i];
  }
  vector<int> b(n);
  for(int i=0;i<q;i++){
    b[a[i]-1]++;
  }
  for(int i=0;i<n;i++){
    if(k-q+b[i]>0){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
}

Measured memory_bytes: 1408
var h,w,i:longint;
    s:ansistring;
begin
  readln(h,w);
  for i:=1 to w+2 do
    write('#');
  writeln;
  for i:=1 to h do
  begin
    write('#');
    readln(s);
    writeln(s,'#');
  end;
  for i:=1 to w+2 do
    write('#');
  writeln;
end.

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

int main()
{
    int n;
    cin >> n;
    int input[n];
    for (int i = 0; i < n; ++i) {
        cin >> input[i];
    }
    int dp [n];
    dp [0] = input[0];
    dp [1] = abs(input[0] - input[1]);
    dp [2] = abs(input[0] - input[2]);
    for (int i = 3; i < n; ++i) 
    {
        int cost1 = abs(input[i] - input[i - 1]) + dp [i - 1];
        int cost2 = abs(input[i] - input[i - 2]) + dp [i - 2];
        dp [i] = min(cost1, cost2);
    }
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<map>
#include<vector>
#include<algorithm> // sort,reverse,min,lower_bound
using namespace std;
#define df 0
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=a;i<(n);i++)
typedef long int li;
// print_item
template<typename T>
void print_item(T x) {cout << x;}
// pair 型の print (map 含む)
template<typename F,typename S>
void print_item(pair<F,S> x);
// map 型
template<typename F,typename S>
void print(map<F,S>& vec,string str="");

// 汎用
void print(auto& vec,string str="");

li inv(li a){
  static vector<li> vec;
  if(vec.size()<= a){ vec.resize(a+1,-1); vec[1]=1;}
  if(vec[a]>0) return vec[a];
  return vec.at(a)=(MOD-(MOD/a))*inv(MOD%a)%MOD;
}

li calc(li h,li w,int flag=0){
  li a=1,b=1;
  if(h>w)swap(h,w);
  static vector<li> fact(h+w+1),ifact(h+w+1),inv(h+w+1);
  if(flag){
    fact[0]=fact[1]=1; ifact[0]=ifact[1]=1;inv[0]=inv[1]=1;
    repa(i,2,h+w+1){
      fact[i]=fact[i-1]*i%MOD;
      inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD;
      ifact[i]=ifact[i-1]*inv[i]%MOD;
    }
    if(df){
      print(fact,"fact");
      print(ifact,"ifct");
      print(inv,"inve");
    }
  }
  li s=fact[h+w];
  (s*=ifact[h])%=MOD;
  return s*ifact[w]%MOD;
}


int main(){
  if(df) printf("*debug mode*\n");
  int h,w,a,b; cin >>h >>w >>a >>b;
  if(a>b){ swap(a,b); swap(h,w); }
  li s=calc(h-1,w-1,1); if(df)printf("%d,%d->%ld\n",h-1,w-1,s);
  li d=0;
  rep(i,a){
    (d+=calc(h-1-i,b-a+i)*calc(i,w-1-b+a-i)%MOD)%=MOD;
    if(df)printf("%ld  ",d);
  }
  (s+=MOD-d)%=MOD;
  printf("%ld",s);
}



void print(auto& vec,string str){
  if(str!="") cout << str << ":";
  for(auto x: vec) {print_item(x); cout << " ";}
  cout << endl;
}

// map 型
template<typename F,typename S>
void print(map<F,S>& vec,string str){
  if(str!="") cout << str << ":";
  for(auto x: vec) {print_item(x); cout << " ";}
  cout << endl;
}

/// confirm df==0 ///


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define float long double
#define f(i,a,b) for(int i = a;i < b;i++)
#define ff(i,a,b)  for(int i = a-1;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false), cin.tie(NULL)
const int mod = 1000000007;
//int to string -> to_string()
//string to int -> stoi()


int32_t main()
{
   IOS;
  
   	    string s1,s2;
   	    cin>>s1>>s2;
   	    int cnt=0;
   	    f(i,0,3)
   	        if(s1[i]==s2[i])
   	            cnt++;
   	    cout<<cnt<<endl;
 
}

Measured memory_bytes: 256
import itertools
N,C = map(int,input().split(' '))
D = [list(map(int,input().split(' '))) for i in [0]*C]
c = [list(map(int,input().split(' '))) for i in [0]*N]


l = [[],[],[]]
n = 0
for i in range(N):
	for j in range(i+1):
		l[n].append(c[i-j][j])
	n = (n+1) % 3
for i in range(N-1):
	for j in range(N-i-1):
		l[n].append(c[i+j+1][N-j-1])
	n = (n+1) % 3

d1,d2,d3 = [[sum([D[j-1][i] for j in l[n]]) for i in range(C)] for n in range(3)]

ans = 1000*500*500
colors = list(range(C))
for c1,c2,c3 in itertools.permutations(colors,3):
	ans = min(ans,d1[c1] + d2[c2] + d3[c3])
print(ans)





Measured memory_bytes: 8356
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>

using namespace std;

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

#define rep(i, a, N) for(int i = a; i < N; i++)
#define rrep(i, a, N) for(int i = a; i >= N; i--)

int main() {
    int N, Q;
    cin >> N >> Q;

    string S;
    cin >> S;

    vector<int> cnt;
    rep(i, 0, N - 1) {
        if (S[i] == 'A' && S[i + 1] == 'C') cnt.push_back(i);
    }

    rep(i, 0, Q) {
        int l, r;
        cin >> l >> r;
        l--;
        r--;
        l = lower_bound(cnt.begin(), cnt.end(), l) - cnt.begin();
        r = lower_bound(cnt.begin(), cnt.end(), r) - cnt.begin();
        cout << r - l << endl;
    }
}

Measured memory_bytes: 1212
S = input()
K = int(input())
ans = ""
for i in range(len(S)):
    if(S[i] != 'a' and K >= (ord('a') - ord(S[i]))%26):
        ans += 'a'
        K -= (ord('a') - ord(S[i]))%26
    else:
        ans += S[i]

K %= 26
ans = ans[:-1] + chr(ord('a') + (ord(ans[-1])-ord('a') + K)%26)
print(ans)


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

void selectSortPrint(int *, int);

int main(void)
{
  int n, *list, i;
  scanf(" %d", &n);
  list = (int *) malloc(sizeof(int[n]));
  for (i = 0; i < n; i++)
    scanf(" %d", list + i);
  selectSortPrint(list, n);
  return 0;
}

void selectSortPrint(int *list, int len)
{
  int i, j, mini, holder;
  int swaps = 0;
  for (i = 0; i < len; i++)
    {
      mini = i; // current smallest element in list[i:len]
      for (j = i; j < len; j++)
	if (list[j] < list[mini])
	  mini = j;
      if (mini != i)
	{
	  holder = list[i];
	  list[i] = list[mini];
	  list[mini] = holder;
	  swaps++;
	}
      printf("%d%s", list[i], i != (len - 1) ? " " : "\n");
    }
  printf("%d\n", swaps);
}
  


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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;

typedef long long int ll;

bool pal(string str){
	string temp = str;
	reverse(all(temp));
	return str == temp;
}

void solve(){
	int N; cin >> N;
	vector<ll> freq(N+1,0), vec(N);
	

	
	for(int i = 0; i < N; i++) {
		cin >> vec[i];
		freq[vec[i]]++;
	}
		
	ll ans = 0;
	for(int i = 1; i <= N; i++){
		ll temp = (freq[i]*(freq[i]-1))/2;
		ans += temp;
	}
	
	for(int i = 0; i < N; i++){
		ll temp = ans-freq[vec[i]]+1;
		cout << temp <<  "\n";
	}

}

int main(){
 	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	int T;
	//cin >> T;
	T = 1;
	while(T--){
		solve();
	}
	return 0;
}




Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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; }
ll mod= 1e9 + 7;



int main(){
  int n;
  cin >>n;
  string s;
  cin >> s;
  int count=0;
  rep(i,n-1){
    if(s[i]=='W' && s[i+1]=='R')count++;
  }
  if(count==0){cout << 0 << endl; return 0;}


int cw=0,cr=0;
int ng=0;
    rep(i,n){
      if(s[i]=='R')cr++;
      if(s[i]=='W')cw++;
    }
    rep(i,cr){if(s[i]=='W')ng++;}

  cout << min({n-cr,n-cw,ng}) << endl;
}

Measured memory_bytes: 3736
#include<iostream>
using namespace std;
int main()
{
    int a,b;

    cin >> a >> b;

    if(a==1&&b==2||a==2&&b==1)
        cout<<3<<endl;
    else if(a==2&&b==3||a==3&&b==2)
        cout<<1<<endl;
    else if(a==1&&b==3||a==3&&b==1)
        cout<<2<<endl;
    else
    return 0;
}


Measured memory_bytes: 3576