akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

template<class T>
constexpr T gcd(T a, T b) {
    if (a < b) gcd(b, a);
    T r = 0;
    while ((r = a % b)) { a = b; b = r; }
    return b;
}
template<class T>
constexpr T lcm(T a, T b) {
    T g = gcd<T>(a, b);
    return a / g * b;
}


int n;
ll m;
ll a[100005];
void solve() {
    cin >> n >> m;
    rep(i, n) cin >> a[i];

    ll lc = 1;
    rep(i, n) lc = lcm(lc, a[i] / 2);

    ll div = 0;
    rep(i, n) {
        ll count = 0;
        while (a[i] % 2 == 0) {
            a[i] /= 2;
            ++count;
        }

        if (i != 0 && count != div) { cout << 0 << endn; return; }
        else div = count;
    }

    cout << (m / lc + 1) / 2 << endn;

}

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


Measured memory_bytes: 1024
sx,sy,tx,ty=map(int,input().split())
dx,dy=tx-sx,ty-sy
print('U'*dy+'R'*dx+'D'*dy+'L'*dx+'L'+'U'*(dy+1)+'R'*(dx+1)+'D'+'R'+'D'*(dy+1)+'L'*(dx+1)+'U')

Measured memory_bytes: 3060
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ld long double


#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}

typedef long long int ll;
#define int ll
#define endl '\n'
const ll mod =1e9+7;
const ll MAX_NODES =200001;
const ll MAX_LOG =50;
const ll inf = 1e18+123;
const int maxn = 200001;

int32_t main()
{

   IOS
   int n,m;
   cin>>n>>m;
   int diff = m;

  int j = 1;
   for(int i = diff - (1 - (diff%2));i>=1;i-=2,j++){
     cout<<j<<" "<<j+i<<endl;
   }
   j = diff - (1-diff%2) + 2;
   for(int i = diff - (diff%2);i>=2;i-=2,j++){
     cout<<j<<" "<<j+i<<endl;
   }

  
  
} 


Measured memory_bytes: 3668
#include <iostream>
#include <string>
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <list>
#include <iterator>
#include <unordered_map>
#include <map>

using namespace std;

using ll = long long;

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

	map<string, ll> strcnt;

	for (int i = 0; i < N; i++)
	{
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		strcnt[s]++;
	}

	ll ans = 0;
	for (pair<string, ll> p : strcnt)
	{
		ans += p.second * (p.second - 1) / 2;
	}
	

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

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL<<60;
const int MAX = 16;
int N;
vector<long long> A;
 
vector<vector<long long>> calc(vector<long long> &a, int limit = 0) {
    vector<vector<long long>> dp(N+1, vector<long long>(MAX, INF));
    for (int j = 0; j < MAX; ++j) dp[0][j] = 0, dp[1][j] = j*2 + limit;
    for (int i = 1; i < N; ++i) {
        long long s = a[N-i-1];
        for (int j = 0; j < MAX; ++j) {
            long long t = a[N-i];
            int need = 0;
            while (s > t) ++need, t *= 4;
            long long add = 0;
 
            if (need >= MAX) {
                add = (need - MAX + 1) * i * 2;
                need = MAX-1;
            }
            dp[i+1][j] = min(dp[i][need] + j * 2 + add + limit , dp[i+1][j]);
            s *= 4;
        }
    }
    return dp;
}
 
long long solve() {
    vector<vector<long long>> suff = calc(A);
    reverse(A.begin(), A.end());
    vector<vector<long long>> pre = calc(A, 1);
    long long res = INF;
    for (int i = 0; i <= N; ++i) {
     res = min(res ,pre[i][0] + suff[N-i][0] );
    }
    return res;
}
 
int main() {
    cin >> N;
    A.resize(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    cout << solve() << endl;
}

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

using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, a, b) for (int64_t i = (a); i < (b); ++i)
const int MOD = 1e9 + 7;
typedef long long ll;
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

int main() {
  // ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  vector<bool> db(n, false);
  vector<int> il(n, 1);
  db[0] = true;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    if (db[a]) {
      if (il[a] >= 2)
        db[b] = true;
      else {
        db[a] = false;
        db[b] = true;
      }
    }
    --il[a];
    ++il[b];
  }
  int odp = 0;
  for (int i = 0; i < n; ++i)
    if (db[i]) ++odp;
  cout << odp << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
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; }

int main(){
    string n;
    cin >> n;
    int sum=0;
    rep(i,n.length()){
        sum+=(n[i]-'0');
    }
    if(sum%9==0) cout << "Yes" <<endl;
    else cout << "No" <<endl;

    return 0;
}


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

int main() {
    int t;
    cin >> t;
    unordered_map<string, int> m;
    m["AC"] = 0;
    m["WA"] = 0;
    m["TLE"] = 0;
    m["RE"] = 0;
    while(t--){
        string s;
        cin >> s;
        ++m[s];
    }
    
    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
    return 0;
}


Measured memory_bytes: 3560
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    string s;
    cin >> s;
    if (s == "AAA" || s == "BBB") cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}














Measured memory_bytes: 256
#include<stdio.h>

int main() {

	int N;
	int i,j;
	int sum,count;
	int Answer[1000],a=0;

	for(;;) {
		scanf("%d",&N);
		if(N==0) break;

		count=0;
		for(i=1;i<=N/2;i++) {
			sum=0;
			for(j=i;N>sum;j++) {
				sum+=j;
				if(sum==N) {
					count++;
					break;
				}
			}
		}
		Answer[a]=count;
		a++;
	}
	for(i=0;i<a;i++)
		printf("%d\n",Answer[i]);
	return 0;
}

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

int main(){
  ll a,b;
  string s;
  cin >> a >> s >> b;
  if(s == "+") cout << a+b << endl;
  else cout << a-b << endl;
  return 0;
}


Measured memory_bytes: 256
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}
function Main(input) {
  input = myconv(input,3);
  if(input.indexOf("1") != -1 && input.indexOf("2") != -1){
     myout("3");
  }else if(input.indexOf("1") != -1 && input.indexOf("3") != -1){
           myout("2");
           }else{
           myout("1");
           }
}
Main(myin());

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,d=0;
  cin >> a;
  if(a >110){
    d = 3;
  }else if(a > 109){
    d = 2;
  }else if(a > 100){
    d = 2;
  }else if(a > 99){
    d = 1;
  }else if(a > 10){
      d = 2;
  }else if(a > 9) {
    d = 1;
  }else if(a > 0) {
    d = 1;
  }
  cout << d << endl;
}


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

#include <math.h>
#include <stdlib.h>


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

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; }

//INT_MAX	2,147,483,647 = 2*1.0e9

const int mod = 1000000007;

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

    vector<ll> A(2*N);
    for(int i = 0; i < N; i++){
        ll a; cin >> a;
        A[i] = a;
        A[i+N] = a;
    }

    ll cnt = 0;
    for(int i = 0; i < N-1; i++){
        for(int j = i+1; j < N; j++){
            if(A[i] > A[j]) cnt++;
        }
    }
    if(K == 1){
        cnt %= mod;
        cout << cnt << endl;
        return 0;
    }

    ll cnt2 = 0;
    for(int i = 0; i < 2*N-1; i++){
        for(int j = i+1; j < 2*N; j++){
            if(A[i] > A[j]) cnt2++;
        }
    }

    ll cntDif = cnt2-cnt*2;
    ll comb = K * (K -1) /2;
    comb %= mod;
    ll ans = cnt * K + cntDif * comb;
    ans %= mod;
    
    cout << ans << endl;

    return 0;
}


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

void solve()
{
    string s;
    cin >> s;
    int n = s.size();
    pair<int, int> p[n + 1];
    p[0] = make_pair(0, 0);
    p[1] = make_pair(1, 0);
    int dp[n + 1];
    dp[0] = 0;
    dp[1] = 0;
    for (int i = 2; i <=n; ++i)
    {
        if (s[i - 1] == 'g')
        {
            if (p[i-1].first > p[i-1].second)
            {
                dp[i] = dp[i - 1] + 1;
                p[i] = p[i - 1];
                p[i].second++;
            }
            else
            {
                dp[i] = dp[i - 1];
                p[i] = p[i - 1];
                p[i].first++;
            }
        }
        else
        {
            if(p[i-1].first > p[i-1].second )
            {
                dp[i] = dp[i - 1];
                p[i] = p[i - 1];
                p[i].second++;
            }
            else 
            {
                dp[i] = dp[i-1]-1;
                p[i] = p[i-1];
                p[i].first++;
            }
        }
    }
    cout << dp[n] << endl;
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 4936
n,k,q=map(int,input().split())
a=[int(input()) for i in range(q)]
p=[k-q for i in range(n)]
for i in range(q):
  p[a[i]-1]+=1
for i in range(n):
  if p[i]>0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 11792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  ll N;
  string ans;
  cin >> N;
  if(N == 0){cout << 0 << endl; return 0;}
  while(N){
    ans += to_string(abs(N) % 2);
    N = (N - abs(N) % 2) / (-2);
  }

  reverse(all(ans));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef bool boool;
typedef long long ll;
#define vl vector<ll>
#define vb vector<boool>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vvl vector<vector<ll>>
#define vvp vector<vector<pair<ll, ll>>>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define rep1(i, n) for (long long i=0; i<(long long)(n); i++)
#define rep2(i, s, e) for (long long i=(s); i<(long long)(e); i++)
#define GET_MACRO(_1,_2,_3,NAME,...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

int main(){
  int n, k;
  cin >> n >> k;
  vb vec(n, false);
  vl cnt(n, 1);
  vec[0] = true;
  rep(i, k){
    int a, b;
    cin >> a >> b;
    a--; b--;
    cnt[a]--; cnt[b]++;
    if(vec[a]) vec[b] = true;
    if(cnt[a] == 0) vec[a] = false;
  }
  int ans = 0;
  rep(i, n){
    if(vec[i] && cnt[i]>0) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4056
from typing import List


def answer(n: int, lrs: List[List[int]]) -> int:
    number_of_people_sitting = 0
    for lr in lrs:
        l, r = lr
        number_of_people_sitting += r - l + 1

    return number_of_people_sitting


def main():
    n = int(input())
    lrs = [map(int, input().split()) for _ in range(n)]
    print(answer(n, lrs))


if __name__ == '__main__':
    main()

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

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

    int ans = 0;
    rep(i, n)
    {
        if (s.substr(i, 3) == "ABC")
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var N, M int
  fmt.Scanf("%d %d\n", &N, &M)
  
  arr := make([]int, N)
  
  SUM := 0
  for i := 0; i < N; i++ {
    	var C int
    fmt.Scanf("%d", &C)
    SUM += C
    arr[i] = C
  }
  
  th := SUM / (4 * M)
  if th * 4 * M != SUM {
    th++
  }
  
  cnt := 0
  for i := 0; i < N; i++ {
    if arr[i] >= th {
      cnt++
    }
    if cnt >= M {
      fmt.Println("Yes")
      return
    }
  }
  fmt.Println("No")
}

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

int main (){
    int h,w;
	while(cin>>h>>w && h && w){
		vector<vector<int>> v(h,vector<int>(w,0));
		for(int i=0;i<h;i++)for(int j=0;j<w;j++) cin>>v[i][j];
		int ans=0;

		for(int y=0;y<10;y++){
			for(int x=0;x<10;x++){
				for(int height=2;height<10;height++){
					for(int width=2;width<10;width++){
						if(y+height>h-1 || x+width>w-1) continue;
						int min_height=1000000000;
						for(int wally=y;wally<=y+height;wally++){
							for(int wallx=x;wallx<=x+width;wallx++){
								if(wally==y || wally==y+height || wallx==x || wallx==x+width) min_height=min(min_height,v[wally][wallx]);
							}
						}

						bool height_ok=true;
						for(int yy=y+1;yy<y+height;yy++){
							for(int xx=x+1;xx<x+width;xx++){
								if(min_height <= v[yy][xx]) height_ok=false;
							}
						}
						if(!height_ok)continue;

						int water=0;
						for(int yy=y+1;yy<y+height;yy++){
							for(int xx=x+1;xx<x+width;xx++){
								water+=max(0,min_height - v[yy][xx]);
							}
						}
						ans=max(ans,water);
					}
				}
			}
		}
		cout<<ans<<endl;
	}
	

}



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

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

    int N, L;
    cin >> N >> L;
    vector<string> V(N);
    for (auto &x : V) cin >> x;
    sort(V.begin(), V.end());
    for (auto &x : V) cout << x;
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_j

#include "algorithm"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

ll N;
V<V<V<double>>> memo;

double dfs(ll one, ll two, ll thr) {
  if (!one && !two && !thr) return 0.0;
  if (memo[one][two][thr] >= 0) return memo[one][two][thr];

  ll s = one + two + thr;
  double res = 1.0 * N / s;
  if (one) res += dfs(one - 1, two, thr) * one / s;
  if (two) res += dfs(one + 1, two - 1, thr) * two / s;
  if (thr) res += dfs(one, two + 1, thr - 1) * thr / s;

  memo[one][two][thr] = res;
  return res;
}

void solve() {
  cin >> N;

  VL cts(4);
  memo = V<V<V<double>>>(N + 1, V<V<double>>(N + 1, V<double>(N + 1, -1)));

  rep(i, N) {
    ll c;
    cin >> c;
    cts[c]++;
  }

  double res = dfs(cts[1], cts[2], cts[3]);
  cout << fixed << setprecision(10) << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 216960
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	
	while (1) {
		int h, w; cin >> h >> w;

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

		for (int i = 0; i < w; i++)cout << "#";
		cout << endl;

		for (int i = 0; i < h - 2; i++) {
			cout << "#";
			for (int j = 0; j < w - 2; j++)cout << ".";
			cout << "#";
			cout << endl;
		}
		

		for (int i = 0; i < w; i++)cout << "#";
		cout << endl;
		cout << endl;
	}
	return 0;
}


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

int main(){
    ll n;
    cin >> n;
    map<ll, int> mp;
    rep(i, n) {
        ll tmp_a;
        cin >> tmp_a;
        ++mp[tmp_a];
    }
    ll ans = 0;
    for ( auto tmp_mp : mp ) {
        if ( tmp_mp.first == tmp_mp.second ) continue;
        if ( tmp_mp.first < tmp_mp.second ) {
            ans += tmp_mp.second - tmp_mp.first;
        }
        else {
            ans += tmp_mp.second;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6272
#include <iostream>
#include <algorithm>
#include <utility>
#include <queue>
#include <vector>
#include <map>
#include <cstring>
#include <set>
using namespace std;

typedef long long ll;

int h, w, a[505][505];
vector<pair<pair<int, int>, pair<int, int>>> r;

int main()
{
    cin >> h >> w;
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j)
            cin >> a[i][j];
    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            if (a[i][j] % 2 == 0)
                continue;
            int dx[] = {-1, 0, 0, 1},
                dy[] = {0, 1, -1, 0}, f = 0;
            for (int k = 0; k < 4; ++k)
            {
                int xx = j + dx[k],
                    yy = i + dy[k];
                if (0 <= xx && xx < w && 0 <= yy && yy < h && a[yy][xx] % 2 == 1)
                {
                    ++a[yy][xx];
                    --a[i][j];
                    f = 1;
                    r.push_back({{i, j}, {yy, xx}});
                    break;
                }
            }
            if (!f)
            {
                int xx = j + (i == h - 1),
                    yy = i + (i != h - 1);
                if (0 <= xx && xx < w && 0 <= yy && yy < h)
                {
                    ++a[yy][xx];
                    --a[i][j];
                    r.push_back({{i, j}, {yy, xx}});
                }
            }
        }
    }
    cout << r.size() << endl;
    for (auto a : r)
        cout << a.first.first + 1 << " " << a.first.second + 1 << " " << a.second.first + 1 << " " << a.second.second + 1 << endl;
}

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

using namespace std;
using   ll=long long;

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

#define endl            "\n"
#define pb              push_back
#define mp              make_pair
#define F               first
#define S               second
#define int             long long int
#define pll                pair<int , int>

#define ALL(v)          v.begin(),v.end()
#define ALLR(v)         v.rbegin(),v.rend()
#define pii             3.14159265358979323
#define inf             LLONG_MAX
#define ones(x)         __builtin_popcount(x)
#define fill(a,b)       memset(a,b,sizeof(a))
#define mod             1000000007
#define hell            998244353

ll mod_pow(ll a,ll b,ll m)
{
    ll res = 1;
    while(b)
    {
        if(b&1)
        {
            res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a)
{
    return mod_pow(a , mod-2 , mod);
}

void solve()
{
	string s , t;
	
	cin >> s >> t;
	
	int ans = 2000;
	
	for(int i = 0; i < s.size() - t.size() + 1; ++i) {
		int cnt = 0;
		
		for(int j = i; j < i + t.size(); ++j) {
			if(s[j] != t[j-i]) {
				cnt++;
			}
		}
		
		ans = min(ans , cnt);
	}
	
	cout << ans;
}

signed main() {
    fast;

    int t = 1;
   
    //cin >> t;

    while(t--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(ll i = 0;i < n;i++)
#define repr(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin >> n;
  vector<ll> a(n+1);
  vector<ll> b(n+1,0);
  rep(i,n){
      cin >> a[i+1];
  }
  FORR(i,n,1){
      ll num = 0;
      for(ll j = i; j<=n; j+=i){
          num += b[j];
      }
      num %= 2;
      if(num != a[i]){
          b[i] = 1;
      }
  }
  cerr << "OK" << endl;
  ll num = 0;
  FOR(i,1,n+1){
      if(b[i])num++;
  }
  cout <<num << endl;
  FOR(i,1,n+1){
      if(b[i])cout << i << endl;
  }

}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(3 * n), maxsubL(3 * n), minsubR(3 * n);
    cin >> a;
    priority_queue<ll, vector<ll>, greater<ll>> pqL;
    ll Lsum = 0;
    for(int i = 0; i < 3 * n; i++) {
        pqL.push(a[i]);
        Lsum += a[i];
        while(pqL.size() > n) {
            Lsum -= pqL.top();
            pqL.pop();
        }
        maxsubL[i] = pqL.size() == n ? Lsum : 0;
    }
    priority_queue<ll> pqR;
    ll Rsum = 0;
    for(int i = 3 * n - 1; i >= 0; i--) {
        pqR.push(a[i]);
        Rsum += a[i];
        while(pqR.size() > n) {
            Rsum -= pqR.top();
            pqR.pop();
        }
        minsubR[i] = pqR.size() == n ? Rsum : lim<ll>::max();
    }
    ll ans = lim<ll>::min();
    for(int i = n; i <= 2 * n; i++) {
        ans = max(ans, maxsubL[i - 1] - minsubR[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9716
// Problem : A - Registration
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define fastio                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define db1(x) cout << #x << "=" << x << endl
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z)                                                       \
  cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define dbp(x) \
  cout << #x << "= {" << (x.first) << ", " << (x.second) << "}" << endl;
#define dbv(v)                         \
  {                                    \
    cout << #v << " : ";               \
    for (auto x : v) cout << x << ' '; \
    cout << endl;                      \
  }
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rep2(i, a, b) for (int i = a; i >= b; i--)
#define die(x) return cout << x << '\n', 0;

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int32_t main() {
  fastio;
  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);
  int testcases;
  testcases = 1;
  // cin>>testcases;

  while (testcases--) {
    string s, t;
    cin >> s >> t;
    if (s.length() == t.length() - 1) {
      if (t.substr(0, t.length() - 1) == s) {
        die("Yes");
      }
      die("No");
    }
    die("No");
  }

  return 0;
}


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

int main()
{
    int N;
    cin >> N;
    int ans = 0;

    ans = N%10;
    if (ans == 3)
    {
        cout << "bon";
    }

    else if (ans == 0 || ans == 1 || ans == 6 || ans == 8)
    {
        cout << "pon";
    }

    else
    {
        cout << "hon";
    }
    
    
        
}

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

using namespace std;

#define INF 1000000007
#define LINF 1000000000000000007

typedef long long Int;
typedef pair<Int,Int> P;

Int gcd(Int x, Int y){
	if(y == 0) return x;
	return gcd(y, x%y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x,y);
}

bool sosuu(Int x){
	bool b = 1;
	if(x == 1) b = 1;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0){b = 0; break;}
	}
	return b;
}

int n, a[100001], b[100001];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		b[i] = a[i];
	}
	
	Int ans[2] = {0};
	
	for(int i = 0; i < n; i++){
		if(i % 2 == 0 && b[i] <= 0){
			ans[0] -= b[i]-1;
			b[i+1] += 1;
		}
		else if(i % 2 == 1 && b[i] >= 0){
			ans[0] += b[i]+1;
			b[i+1] -= 1;
		}
		else b[i+1] += b[i];
	}
	for(int i = 0; i < n; i++){
		if(i % 2 == 1 && a[i] <= 0){
			ans[1] -= a[i]-1;
			a[i+1] += 1;
		}
		else if(i % 2 == 0 && a[i] >= 0){
			ans[1] += a[i]+1;
			a[i+1] -= 1;
		}
		else a[i+1] += a[i];
	}
	cout << min(ans[0],ans[1]) << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    double A, B, P, Q, R;
    cin >> A >> B >> P >> Q >> R;
    cout << setprecision(10) << (P * B - Q * (B - A)) / (Q + R) + max(A, B) << endl;

}



Measured memory_bytes: 3280
#include "bits/stdc++.h"
#define mod 1000000007
using namespace std;


long int modpow(int a, long int p) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		long int r = p / 2;
		long int ans = modpow(a, r);
		return ans * ans % mod;
	}
	else {
		return a * modpow(a, p - 1) % mod;
	}
}

long int modcombi(int a, int c) {
	int i;
	long int ans;
	long int bunsi = 1;
	long int bunbo = 1;
	for (i = 0; i < c; i++) {
		bunsi = bunsi * (a - i) % mod;
		bunbo = bunbo * (i + 1) % mod;
	}
	ans = bunsi * modpow(bunbo, mod - 2) % mod;
	return ans;

}


int main(void) {
	int n, m;
	scanf("%d%d", &n, &m);
	int copym = m;
	int long ans = 1;
	int i;
	for (i = 2; i*i <= copym; i++) {
		if (copym%i == 0) {
			int count = 0;
			while (copym % i == 0) {
				count++;
				copym = copym / i;

			}
			ans = ans * modcombi(count + n - 1, n - 1);
			ans = ans % mod;
		}
	}
	if (copym != 1) {
		ans = ans * modcombi(n + 1 - 1, n - 1);
		ans = ans % mod;
		copym = copym / copym;
	}


	printf("%ld", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k,x;
    cin>>k>>x;
    int a = x-1;
    for(int i=x-k+1;i<=a;i++){
        cout<<i<<" ";
    }
    for(int i=x;i<x+k;i++){
        cout<<i<<" ";
    }
    return 0;
    
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <map>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m; cin >> n >> m;
    vector<ll> A(n);
    for(int i = 0; i < n; i++) cin >> A[i];
    vector<ll> B(n + 1, 0);
    map<ll, ll> mp;
    for(int i = 1; i <= n; i++)
    {
        B[i] += (B[i - 1] + A[i - 1]) % m;
        mp[B[i]]++;
    }
    ll ans = 0;
    for(auto x : mp)
    {
        if(x.first == 0) ans += x.second;
        ans += x.second * (x.second - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
typedef pair<double,double> Pd;
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<double> x(n),y(n);
	rep(i,n){
		cin>>x[i]>>y[i];
	}
	auto dist=[&](Pd a,Pd b){
		return sqrt((a.fi-b.fi)*(a.fi-b.fi)+(a.se-b.se)*(a.se-b.se));
	};
	auto func=[&](double rx,double ry){
		double ret=0;
		rep(i,n){
			chmax(ret,dist(Pd(rx,ry),Pd(x[i],y[i])));
		}
		return ret;
	};
	auto g=[&](double rx){
		double l=0,r=1000;
		rep(i,100){
			double nel=(2*l+r)/3,ner=(l+2*r)/3;
			if(func(rx,nel)>func(rx,ner)) l=nel;
			else r=ner;
		}
		return func(rx,r);
	};
	double l=0,r=1000;
	rep(i,100){
		double nel=(2*l+r)/3,ner=(l+2*r)/3;
		if(g(nel)>g(ner)) l=nel;
		else r=ner;
	}
	cout<<setprecision(10)<<g(r)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n,k,i,x;
    cin>>n>>k;
    x=1;
    for(i=1;i<=n;i++)
        if(x*2>=x+k)
        {
            x=x+k;
        }
        else
            x=x*2;
    cout<<x;
    return 0;
}


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

int main(){
    int ans1,ans2;
    int h,w;cin>>h>>w;
    string s;
    fol(i,h){
        fol(j,w){
            cin>>s;
            if (s=="snuke"){
                ans1=j;
                ans2=i;
            }
        }
    }
    cout << (char)('A'+ans1)<<1+ans2<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        if (n <= 111) Console.WriteLine(111);
        else if (n <= 222) Console.WriteLine(222);
        else if (n <= 333) Console.WriteLine(333);
        else if (n <= 444) Console.WriteLine(444);
        else if (n <= 555) Console.WriteLine(555);
        else if (n <= 666) Console.WriteLine(666);
        else if (n <= 777) Console.WriteLine(777);
        else if (n <= 888) Console.WriteLine(888);
        else if (n <= 999) Console.WriteLine(999);
    }
}

Measured memory_bytes: 11092
import std;
import core.bitop;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "x", long, "c");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    auto s = sread();
    auto t = sread();
    auto nexts = new long[][](s.length, 26);
    foreach (ref e; nexts)
        e[] = INF;

    foreach_reverse (i; iota(2 * s.length))
    {
        foreach (j; iota(26))
        {
            if (s[(i + 1) % s.length] == 'a' + j)
                nexts[i % s.length][j] = 1;
            else
                nexts[i % s.length][j] = nexts[(i + 1) % s.length][j] + 1;
        }
    }

    long idx = s.countUntil(t[0]);
    foreach (e; t[1 .. $])
    {
        if (idx < 0)
            break;
            
        if (nexts[idx % s.length][e - 'a'] <= s.length)
            idx += nexts[idx % s.length][e - 'a'];
        else
            idx = -1;
    }

    writeln(idx >= 0 ? idx + 1 : idx);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 31396
#include<bits/stdc++.h>
#define pb push_back 
using namespace std;

const int maxn=105;
typedef long long ll;

ll n,m,ans,W;
ll w[maxn],v[maxn];
priority_queue<ll>q[15];
vector<ll>a[15];

int main()
{
	ll i,j,k,l;
	scanf("%lld%lld",&n,&W);
	for(i=1;i<=n;++i)
	  scanf("%lld%lld",&w[i],&v[i]),
	  q[w[i]-w[1]].push(v[i]);
	
	for(i=0;i<=3;++i)
	{
		a[i].pb(0);
		while(!q[i].empty())
		{
			a[i].pb(a[i][a[i].size()-1]+q[i].top());
			q[i].pop();
		}
	}
	
	ll len[5];
	for(i=0;i<=3;++i) len[i]=a[i].size()-1;
	
	//for(i=0;i<=3;++i)
	  //for(j=0;j<len[i];++j)
	
	for(i=0;i<=len[0];++i)
	  for(j=0;j<=len[1];++j)
	    for(k=0;k<=len[2];++k)
	      for(l=0;l<=len[3];++l)
	      {
	      	if(j+2*k+3*l+(i+j+k+l)*w[1]<=W)
	      	{
	      		ans=max(ans,a[0][i]+a[1][j]+a[2][k]+a[3][l]);
	      	}
	      }
	
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int min(int x,int y)
{
	return x>y?y:x;
}
int main()
{
	int n;
	int a[205];
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	scanf("%d",&a[i]);
	sort(a,a+n);
	int ans=0x3f3f3f;
	int sum;
	for(int i=a[0];i<=a[n-1];i++)
	{
		sum=0;
		for(int j=0;j<n;j++)
		{
			sum+=(i-a[j])*(i-a[j]);
		}
		ans=min(ans,sum);
	}
	printf("%d\n",ans);
}

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

#define REP(i, n, N) for(ll i=(n);i<(N);i++)
#define RREP(i, n, N) for(ll i=(N-1);i>=(n);i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(), (v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main() {

    string s;
    cin>>s;

    REP(i,0,s.size()){
        if(s[i] == '1'){
            s[i] = '9';
        }else{
            s[i] = '1';
        }
    }

    cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int l,r,m;
  cin>>l>>r>>m;
  int l_limit=l/m;
  int r_limit=r/m;
  int answer=r_limit-l_limit;
  if(l%m==0){
    answer++;
  }
  cout<<answer<<endl;
}

Measured memory_bytes: 3120
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    char str[3][205]={0};
    scanf("%s", str[0]);
    scanf("%s", str[1]);
    scanf("%s", str[2]);

    printf("A%cC\n", str[1][0]);

    return 0;
}




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

int main(){
  int N; cin >> N;
  vector<ll> a(3*N);
  priority_queue<ll, vector<ll>, greater<ll> > left;
  priority_queue<ll> right;
  vector<ll> sum_left(N + 1, 0), sum_right(N + 1, 0);
  for(int i = 0; i < 3*N; i++){
    cin >> a[i];
    if(i < N){
      left.push(a[i]);
      sum_left[0] += a[i];
    }
    if(i >= 2*N){
      right.push(a[i]);
      sum_right[N] += a[i];
    }
  }
  for(int i = 1; i <= N; i++){
    sum_left[i] = sum_left[i - 1] + a[N + i - 1];
    left.push(a[N + i - 1]);
    sum_left[i] -= left.top();
    left.pop();
  }
  for(int i = 1; i <= N; i++){
    sum_right[N - i] = sum_right[N - i + 1] + a[2*N - i];
    right.push(a[2*N - i]);
    sum_right[N - i] -= right.top();
    right.pop();
  }
  ll ans = sum_left[0] - sum_right[0];
  for(int i = 1; i <= N; i++){
    ans = max(ans, sum_left[i] - sum_right[i]);
  }
  cout << ans << endl;
} 

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

//1-indexedであることに注意

inline int Calcu(int a,int b){
    return a + b;
}

class SegTree{
    public:
        int n;
        int g;
        std::vector<int> data;

        SegTree(std::vector<int> a, int _g){
            g = _g;
            for (n = 1; n < (int) a.size(); n *= 2);
            data.resize(n * 2, g);
            for (int i = 0; i < (int) a.size(); i++) data[i + n] = a[i];
            for (int i = n - 1; i >= 1; i--)
                data[i] = Calcu(data[i * 2], data[i * 2 + 1]);
        }
        int rec(int l, int r, int node, int node_l, int node_r) {
            if (node_r <= l || node_l >= r) return g;
            if (node_l >= l && node_r <= r) return data[node];
            int mid = (node_l + node_r) / 2;
            return Calcu(
                rec(l, r, node * 2, node_l, mid),
                rec(l, r, node * 2 + 1, mid, node_r));
        }

        int get(int l,int r){
            return rec(l,r,1,0,n);
        }

        void assign(int index, int val){
            data[index += n] += val;
            for(;index /= 2;)
                data[index] = Calcu(data[index * 2],data[index * 2 + 1]);
        }
};



int main()
{
    int n,q;
    std::cin >> n >> q;
    std::vector<int> tmp(n,0);
    SegTree tree(tmp,0);
    std::vector<int> ans;
    for(int i = 0; i < q; i++){
        int flag; std::cin >> flag;
        int x,y;
        std::cin >> x >> y;

        if(flag == 0){
            x--;
            tree.assign(x,y);
        }else{
            x--;y--;
            ans.push_back(tree.get(x, y + 1));
        }
    }
    for(int i = 0; i < (int)ans.size(); i++)std::cout << ans[i] << std::endl;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;typedef vector<ll> vll;
ll mod = 1000000007, INF = 10000000000000000;
ll gcd(ll a, ll b){if(b==0){return a;}return gcd(b, a%b);}
// for (ll i = 0; i < n; i++) {
// sort(.begin(),.end());
int main(){
  ll n, m, index;
  cin >> n >> m;
  for (ll i = 1; i <= n; i++) {
    ll x = abs(m + i - 1);
    if (INF > x) {
      INF = x;
      index = i;
    }
  }
  
  cout << n*m+n*(n-1)/2-(m+index-1) << endl;
  
}

Measured memory_bytes: 256
N = int(input())
P = list(map(float, input().split()))
DP = [[0]*(N+1)for _ in range(N+1)]
DP[0][0] = 1
for i in range(1,N+1):
    for j in range(N+1):
        if i < j:
            DP[i][j] = 0
        else:
            DP[i][j] = P[i-1] * DP[i-1][j-1] + (1 - P[i-1]) * DP[i-1][j]
print(sum(DP[N][N//2 + 1:]))

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

#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int, int>>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int, int>
#define int long long int
#define inf INT_MAX
#define _inf INT_MIN
#define prDouble(x) cout<< fixed<<setprecision(10) << x
#define whilet int t;cin>>t;while(t--)
const int N = 100005;
const int mod = 1e9 + 7;

double dp[301][301][301];

double func(int& n, int x, int y, int z) {

	if (x < 0 || y < 0 || z < 0 ) return 0;
	if (x == 0 and y == 0 and z == 0 ) return 0;
	if (dp[x][y][z]  > -0.9) return dp[x][y][z];

	double expectedValue = n + x * func(n, x - 1, y, z) + y * func(n, x + 1, y - 1, z) + z * func(n, x, y + 1, z - 1);
	return dp[x][y][z] = expectedValue / double( x + y + z);
}


void solve() {

	int n, one = 0, two = 0, three = 0;

	memset(dp, -1, sizeof(dp));
	cin >> n;
	for (int i = 0; i < n; i++) {
		int numberOfDishes;
		cin >> numberOfDishes;
		if (numberOfDishes == 1) one++;
		else if (numberOfDishes == 2) two++;
		else three++;

	}

	prDouble(func(n, one, two, three)) ;

}

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


int32_t main()
{
	init();
	// whilet solve();
	solve();
}

Measured memory_bytes: 216872
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,n,k=0,f=0,g=0,sum=0,a[1000],max=0;
    memset(a,0,sizeof(a));
    map<string,int>f1;
    map<string,int>f2;
    map<string,int>f3;
    cin>>m;
    string s[m+10];
    getchar();
    for(int i = 0; i < m; i++)
    {
        cin>>s[i];
        f1[s[i]]++;
        //cout<<s[i]<<" "<<f1[s[i]]<<endl;
    }

    cin>>n;
    string s1[n+10];
    getchar();
    for(int i = 0; i < n; i++)
    {
        cin>>s1[i];
        f2[s1[i]]++;
    }

    for(int i = 0; i < m; i++)
    {
        if(f3[s[i]]!=-1)
        {
            f = (f1[s[i]]-f2[s[i]]);
            //cout<<f1[s[i]]<<" "<<f2[s[i]]<<endl;
            sum = f;
            if(max < sum)
            {
                max = sum;
            }
            //cout<<sum<<endl;
            f3[s[i]] = -1;
        }

    }


    cout<<max<<endl;



}



Measured memory_bytes: 256