akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;



int main(){

ll x,y,z;cin >> x >> y >> z;
cout << (x-z)/(y+z) << endl;
return 0;
}





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

using namespace std;
int main()
{
   ll k,a,b,c=0;
   cin>>k>>a>>b;
   c=k-a%k;
   if(a%k==0||a+c<=b)
    cout<<"OK"<<endl;
   else
    cout<<"NG"<<endl;
}



Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;

int F(long long x)
{
	int ans=0;
	while(x)
	{
		ans++;
		x/=10;
	}
	return ans;
}

int main()
{
	long long n;
	cin>>n;
	int Ans=11;
	for(long long i=1;i*i<=n;i++)
		if(n%i==0) Ans=min(Ans,max(F(i),F(n/i)));
	cout<<Ans<<endl;
	return 0;
}

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

int main() {
  int N;
  cin>>N;
  
  double ans=0;
  
  for(int i=0;i<N;i++){
    double x;
    string u;
    cin>>x>>u;
    
    if(u=="JPY")
      ans+=x;
    if(u=="BTC")
      ans+=x*380000;
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

ll binpow(ll a, ll b) {
    if (b == 0)
    {
        return 1;
    }
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
    {
        return res * a;
    }
    return res;
}

ll gcd(ll a,ll b)
{
    if (b==0) return a;
    return gcd(b,a%b);
}

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if (!a)
        cout<<1;
    if (!b)
        cout<<2;
    if (!c)
        cout<<3;
    if (!d)
        cout<<4;
    if (!e)
        cout<<5;
    return 0;
}

Measured memory_bytes: 3540
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var S = ReadLine();
            var ans = new List<char>();
            foreach (var s in S)
                if (s == 'B')
                {
                    if (ans.Any())
                        ans.RemoveAt(ans.Count - 1);
                }
                else
                    ans.Add(s);
            WriteLine(string.Join("", ans));
        }
    }
}

Measured memory_bytes: 26580
#include<stdio.h>
int main(){
  int n,n2,i,j;
  int ori=0,nobori=0;
  int b1=0,b2;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&n2);
    for(j=0;j<n2;j++){
      scanf("%d",&b2);
      if(j==0)b1=b2;
      if(b1<b2){
	if(nobori<b2-b1){
	  nobori=b2-b1;
	}
	//	b1=b2;
      }
      if(b1>b2){
	if(ori<b1-b2){
	  ori=b1-b2;
	}
      }
      b1=b2;
    }
      printf("%d %d\n",nobori,ori);
      nobori=0;
      ori=0;
  }
  return 0;
}

Measured memory_bytes: 596
def merge(A, l, m, r):
    L = A[l:m] + [10 ** 9 + 1]
    R = A[m:r] + [10 ** 9 + 1]
    i, j, p, q = 0, 0, 0, 0
    for k in range(l, r):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
            q += p
        else:
            A[k] = R[j]
            j += 1
            p += 1
    global cnt
    cnt += q

def mergeSort(A, l, r):
    if r - l > 1:
        m = (l + r) // 2
        mergeSort(A, l, m)
        mergeSort(A, m, r)
        merge(A, l, m, r)

n = int(input())
A = list(map(int, input().split()))
cnt = 0
mergeSort(A, 0, n)
print(cnt)

Measured memory_bytes: 30432
import sys
from heapq import *

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    def get_group(k):
        g = pd[k]
        if g < 0:
            return k
        gg = get_group(g)
        pd[k] = gg
        return gg

    def merge(j, k):
        g1 = get_group(j)
        g2 = get_group(k)
        if g1 != g2:
            d1 = -pd[g1]
            d2 = -pd[g2]
            if d2 > d1:
                g1, g2 = g2, g1
            pd[g2] = g1
            if d1 == d2:
                pd[g1] -= 1

    hp = []
    n, h, w = map(int, input().split())
    pd = [-1] * (h + w + 2)  # 親(parent)と深さ(depth)。0以上は親。負の場合、そのノードが根で絶対値が深さ。
    pd[0] = -(h + w + 2)
    for _ in range(n):
        r, c, a = map(int, input().split())
        heappush(hp, [-a, r, h + c])
    cnt = h + w
    ans = 0
    while cnt and hp:
        a, r, c = heappop(hp)
        gr = get_group(r)
        gc = get_group(c)
        if gr + gc == 0: continue
        if gr == gc:
            merge(gr, 0)
        else:
            merge(gr, gc)
        ans -= a
        cnt -= 1
    print(ans)

main()


Measured memory_bytes: 24432
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>


using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long ll;

int main() {

    ll N;
    cin >> N;

    ll res;

    vector <ll> a(N);
    vector <ll> sorted_a(N);

    REP(i,N)
    {
        cin >> a[i];
    }

    sorted_a = a;

    sort(sorted_a.begin(), sorted_a.end(),greater<ll>());

    REP(i,N)
    {
        REP(j,N)
        {
            if(j == 0 && a[i] == sorted_a[j])continue;

            cout << sorted_a[j] << endl;
            break;
        }
    }
    return 0;

}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define mod 26
#define S str[i]
using namespace std;
string str;
 
string solve(){
  string res;
  stack <int> st;
  for(int i=0;i<str.size();i++){
    int cnt=0;
    while(S=='+'||S=='-')cnt+=(S=='+')-(S=='-'),i++;
    
    if(cnt) res+=((S-'A')+cnt%mod+mod)%mod+'A';
    else if(S!='['&&S!=']')res += S;
    if(S=='?')res[res.size()-1]='A';
    if(S=='[')st.push(res.size());
    if(S==']')reverse(res.begin()+st.top(),res.end()),st.pop();
  }
  return res;
}
 
int main(){
  while(cin>>str&&str!=".")cout <<solve()<<endl;
  return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <set>
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    ll place[N + 1];
    for (int i = 1; i <= N; ++i) {
        ll a;
        cin >> a;
        place[a] = i;
    }

    ll ans = 0;
    set<ll> used = {0, N + 1};
    for (int i = 1; i <= N; ++i) {
        ll r, l;
        auto itr = used.lower_bound(place[i]);
        r = *itr;
        l = *(--itr);
        ans += i * (place[i] - l) * (r - place[i]);
        used.insert(place[i]);
    }

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


Measured memory_bytes: 11136
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
using namespace std;

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    int A, B, C;
    cin >> A >> B >> C;

    if(A <= C && C <= B) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashMap<String, Integer> map = new HashMap<>();
		String[] ans = new String[]{"AC", "WA", "TLE", "RE"};
		int[] counts = new int[ans.length];
		for (int i = 0; i < n; i++) {
		    String s = sc.next();
		    for (int j = 0; j < ans.length; j++) {
		        if (s.equals(ans[j])) {
		            counts[j]++;
		            break;
		        }
		    }
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < ans.length; i++) {
		    sb.append(ans[i]).append(" x ").append(counts[i]).append("\n");
		}
		System.out.print(sb);
	}
}


Measured memory_bytes: 58364
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from bisect import bisect_left

n, m = map(int, readline().split())
py = [list(map(int, readline().split())) for _ in range(m)]
check = sorted(py)
idx = [0] * (n + 1)
memo = 0
for i, (p, _) in enumerate(check):
    if memo != p:
        idx[p] = i
        memo = p
for p, y in py:
    yy = str(bisect_left(check, [p, y]) - idx[p] + 1)
    p = str(p)
    print('0' * (6 - len(p)) + p + '0' * (6 - len(yy)) + yy)


Measured memory_bytes: 33428
//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 <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

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())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++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

const int MAX_N = 110;
const int MAX_V = 100100;

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

string s, t;
int dp[3100][3100] = { 0 };

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

	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < t.size(); j++) {
			if (s[i] == t[j])chmax(dp[i + 1][j + 1], dp[i][j] + 1);
			chmax(dp[i + 1][j + 1], dp[i + 1][j]);
			chmax(dp[i + 1][j + 1], dp[i][j+1]);
		}
	}

	string res = "";
	int i = (int)s.size(), j = (int)t.size();

	while (i > 0 && j > 0) {
		//上から来ていた場合
		if (dp[i][j] == dp[i - 1][j]) {
			i--;
		}
		//左から来ていた場合
		else if (dp[i][j] == dp[i][j - 1]) {
			j--;
		}
		//文字が一致していて左上から来ていた場合
		else {
			res = s[i - 1] + res;
			i--; j--;
		}
	}

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 37120
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int X, Y;
    cin >> X >> Y;

    int x = (4*X-Y) % 2;
    int y = (Y-2*X) % 2;
    if (x || y  || 4*X-Y < 0 || Y - 2*X < 0) no;
    else yes;
    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc170/abc170_b && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc170/abc170_b && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc170/abc170_b && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int n,m;
	float s=0;
	cin>>n>>m;
	int a[n+1];
	for(int i=1; i<=n; i++)
	{
		cin>>a[i];
		s+=a[i];
	} 
	sort(a+1,a+n+1);
	if(a[n-m+1]>=s/(4*m))
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    N = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    res = 0
    n = 0
    for i in range(N):
        res += min(a[i], b[i]+n)
        c = max(a[i]-n, 0)
        n = max(b[i]-c, 0)
    res += min(n, a[-1])
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 19000
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define F(i,n) for(int i=0; i<n; i++)

int main()
{
    int N; cin >> N;
    vector<int> h(N); F(i,N) cin >> h[i];
    vector<int> DP(N,0); DP[1] = DP[0] + abs(h[1]-h[0]);

    for(int i=2; i<N; i++) DP[i] = min(DP[i-1] + abs(h[i-1]-h[i]), DP[i-2] + abs(h[i-2]-h[i]));
    cout << DP[N-1];
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1000000 + 10;
const int MOD = 1000000007;

inline int inc(int a, int b) { return (a + b >= MOD) ? (a + b - MOD) : (a + b); }
inline int dec(int a, int b) { return (a >= b) ? (a - b) : (a + MOD - b); }
inline int mul(int a, int b) { return 1LL * a * b % MOD; }

inline int power(int x, int k) {
	int tmp = 1;
	while(k) {
		if(k & 1) tmp = mul(tmp,x);
		x = mul(x,x);
		k >>= 1;
	}
	return tmp;
}

int n, fac[maxn], ifac[maxn], f[maxn];

inline int C(int n, int m) {
	if(n < 0 || m < 0 || n < m) return 0;
	return mul(fac[n],mul(ifac[m],ifac[n - m]));
}

int main() {
//	freopen("data.in","r",stdin);
  scanf("%d", &n);
	fac[0] = ifac[0] = 1;
	for(int i = 1;i <= n;i ++) fac[i] = mul(fac[i - 1],i);
	ifac[n] = power(fac[n],MOD - 2);
	for(int i = n - 1;i >= 1;i --) ifac[i] = mul(ifac[i + 1],i + 1);
	int Ans = 0;
	int lim = (n + 1) / 2;
	for(int i = lim;i < n;i ++) {
		int xs = mul(fac[i],fac[n - 1 - i]);
		f[i] = mul(xs,C(i - 1,n - i - 1));
	}
	f[lim - 1] = 0;
	for(int i = lim;i < n;i ++) {
		Ans = inc(Ans,mul(i,dec(f[i],f[i - 1])));
	}
	printf("%d\n", Ans);
	return 0;
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
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 main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    int a[N];
    int b[N];
    int c[N];
    REP(i,N){
        cin>>a[i]>>b[i]>>c[i];
    }
    vector<vector<ll>> vec;
    vector<ll> v;
    v.assign(3,0);
    vec.assign(N+1,v);
    REP(i,N){
        vec[i+1][0]=max(vec[i][1]+a[i],vec[i][2]+a[i]);
        vec[i+1][1]=max(vec[i][0]+b[i],vec[i][2]+b[i]);
        vec[i+1][2]=max(vec[i][0]+c[i],vec[i][1]+c[i]);
        
    }
    cout<<max(vec[N][0],max(vec[N][1],vec[N][2]))<<endl;
    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
string s = "CODEFESTIVAL2016";

int main() {
    string a;
    cin >> a;
    int res = 0;
    for (int i = 0; i < a.size(); i++) {
        res += a[i] != s[i];
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using vc=vector<char>;
using vvc=vector<vc>;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using tiii = tuple<int,int,int>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int MOD=1e9+7;

ll power(ll a, int b) {
  if(!b) return 1;
  ll c = power(a, b/2);
  if(b%2) return c*c%MOD*a%MOD;
  return c*c%MOD;
}

int main() {
  int N;
  cin >> N;
  cout << (power(10,N)+2*(MOD-power(9,N))+power(8,N))%MOD << endl;
}

Measured memory_bytes: 3616
n, k = gets.chomp.split.map(&:to_i)
dislikes = gets.chomp.split
likes = ("0".."9").to_a - dislikes

max = likes.max
l = n.to_s.size
l += 1 if (max * l).to_i < n
candidate = nil
likes.repeated_permutation(l){|arr|
    candidate = arr.join.to_i
    break if candidate >= n
}
puts candidate


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

using namespace std;

main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	
	int res = 0;
	
	for(int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		
		if(x >= k)
			res++;
	}
	
	cout << res;
}

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

using namespace std;

int ans;
char a[4], b[4];

int main() {
	for(int i = 1; i <= 3; ++i) cin >> a[i];
	for(int i = 1; i <= 3; ++i) cin >> b[i];
	for(int i = 1; i <= 3; ++i) if(a[i] == b[i]) ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define R register
typedef long long ll;

const int MN = 505;

ll pr[MN << 1];

int n; bool b[MN * MN];

int main() {
	std::ios::sync_with_stdio(false);

	std::cin >> n;

	pr[0] = 1;
	for (R int i = 2, p = 0; p <= (n << 1); ++i)
		if (!b[i]) {
			pr[++p] = i;
			for (R int j = i << 1; j <= 1e4; j += i)
				b[j] = 1;
		}

	for (R int i = 1; i <= n; std::cout << std::endl, ++i)
		for (R int j = 1; j <= n; ++j)
			if ((i + j) & 1)
				std::cout << pr[i + j - 1 >> 1] * pr[i + j + 1 >> 1] * pr[i - j + 3 * n + 1 >> 1] * pr[i - j + 3 * n - 1 >> 1] + 1 << " ";
			else std::cout << pr[i + j >> 1] * pr[i - j + 3 * n >> 1] << " ";
	return 0;
}

Measured memory_bytes: 3200
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

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

  int a, b, c; cin >> a >> b >> c;
  if (a < b && b < c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

using namespace std;

int main(){
	long long int count=0,N;
	cin >> N;
	long long int A[N],B[N];
	for(int i=0;i<N;i++){
		cin >> A[i] >> B[i];
	}
	for(int i=N-1;i>=0;i--){
		if((A[i]+count)%B[i]!=0){
			count+=(B[i]-(A[i]+count)%B[i]);
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a;
  string s;
  cin>>a;
  cin>>s;
  if(a<3200)
  {
    cout<<"red"<<endl;
  }
  else
  {
    cout<<s<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int odd_count = 0;
        int even_count = 0;
        for (int i = 0; i < N; i++) {
            int x = scan.nextInt();
            if (x % 2 == 1) {
                odd_count += 1;
                continue;
            }
            even_count += 1;
        }
        even_count += odd_count / 2;
        int previous = 0;
        while (previous != even_count) {
            previous = even_count;
            even_count = even_count / 2 + even_count % 2;
        }
        odd_count %= 2;
        System.out.println(even_count + odd_count == 1 ? "YES" : "NO");
    }
}


Measured memory_bytes: 48304
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
typedef pair<int, int> P;

int main(){
    int i, count[3] = {};
    string s;
    cin >> s;
    for(i=0; i<s.length(); i++){
        count[s[i]-'a']++;
    }
    if(max(count[0], max(count[1], count[2])) - min(count[0], min(count[1], count[2])) > 1){
        cout << "NO\n";
    }else{
        cout << "YES\n";
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define RI(a) scanf("%d",&a)
#define RII(a,b) scanf("%d%d",&a,&b)
#define RIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
//}}}
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;

int dis(int a,int b){
	return (a>b)?a-b:b-a;
}

int main()
{
	int x,a,b;
	cin>>x>>a>>b;
	if(dis(x,a)>dis(x,b)) puts("B");
	else puts("A");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 3005
const int INF = 1e9 + 7;

int used[ARRAY_MAX];

int main() {

	int n, m;
	cin >> n;
	auto a = make_v<int>(n + 10);
	fill_v(a, 0);

	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		used[a[i]] = 1;
	}

	cin >> m;

	for (int i = 0; i < m; i++)
	{
		int tmp;
		cin >> tmp;
		if (a[tmp] + 1 <= 2019)
		{
			if (used[a[tmp] + 1] == 0)
			{
				used[a[tmp]] = 0;
				used[a[tmp] + 1] = 1;
				a[tmp]++;
			}
		}
	}

	for (int i = 1; i <= n; i++)
	{
		cout << a[i] << endl;
	}
	
}






Measured memory_bytes: 3104
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod   1000000007
#define PI 2*acos(0.0)
#define all(r)(r).begin(),(r).end()
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define inf 1000000000000000000
#define N 110
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};


//=============================================ASIFAZAD==============================================
string num;
int k, n;
ll dp[120][5][2];

ll dig_dp(int pos, int cnt, int sm)
{
    if(pos == n)
        return cnt==k;
    if(cnt > k)
        return 0;
    if(dp[pos][cnt][sm] != -1)
        return dp[pos][cnt][sm];
    int lim = (sm?9:(int)(num[pos] - '0'));
    ll res = 0;
    for(int i = 0; i<= lim; i++)
    {
        int nsm = sm;
        if(i < lim)
            nsm = 1;
        int ncnt = (i?cnt + 1:cnt);
        res += dig_dp(pos + 1, ncnt, nsm);
    }
    return dp[pos][cnt][sm] = res;
}


int32_t main()
{
    io;
    cin>>num>>k;
    n = num.size();
    memset(dp, -1, sizeof(dp));
    cout<<dig_dp(0, 0, 0);
    return 0;
}


Measured memory_bytes: 3524
#include <iostream>

using namespace std;

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

  cin >> a >> b >> c;

  if(((a + b )== c) ||( (b + c) == a ) || ((c + a )==b)  )
    cout << "Yes" << endl;
  else
    cout << "No" << endl;


  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	void rect(){
		Scanner s = new Scanner(System.in);
		int h = s.nextInt();
		int w = s.nextInt();
		while(h!=0||w!=0){
			for(int i = 0;i<h;i++){
				for(int j = 0;j<w;j++){
					if(j == 0 || j == w-1 || i == 0 || i == h-1){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
				}
				System.out.println("");
			}
			System.out.println("");
			h = s.nextInt();
			w = s.nextInt();
		}
	}
	public static void main(String args[]){
		Main m = new Main();
		m.rect();
	}
}

Measured memory_bytes: 33020
X, Y = map(int, input().split())

S = 0
if X== 1:
    S += 300000
elif X == 2:
    S += 200000
elif X == 3:
    S += 100000

if Y== 1:
    S += 300000
elif Y == 2:
    S += 200000
elif Y== 3:
    S += 100000

if X == 1 and Y == 1:
    S += 400000

print (S)


Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;

int P[10010];
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対グラフ

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

int main(){
    int n,l;
    cin >>n>>l;
    int sum=0;
    rep(i,n){
        sum+=l+i;
    }
    if(l+n-1<0){
        cout<<sum-(l+n-1)<<endl;
    }else if(l>0){
        cout<<sum-l<<endl;
    }else{
        cout<<sum<<endl;
    }
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,sum,mul;
    cin>>a>>b;
    sum=a+b;
    mul=a*b;
    if(sum==15) cout<<"+"<<endl;
    else if(mul==15) cout<<"*"<<endl;
    else        cout<<"x"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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(){
    int n;
    cin>>n;
    int ans=1;
    int num=1;
    while(num<=n){
        num*=2;
    }
    cout<<num/2<<endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
A, B, C, D = [iS for iS in S]

for i in range(2**3):
    a = [1&(i>>j) for j in range(3)]
    ind = set([i for i,x in enumerate(a) if x==1])
    
    sign = 1
    tmp=0
    nums=[]
    ans = ""
    for j in range(4):
        tmp = sign * int(S[j])
        ans += S[j]
        if j in ind:
            sign = -1
            ans+="-"
        else:
            sign = 1
            ans+="+"
        nums += [tmp]

    if sum(nums)==7:
        print(ans[:-1] + "=7")
        break
    


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int (i) = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int (i) = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int (i) = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).begin(),(v).end(),greater<>()
#define Pi 3.1415926535
#define MOD 1000000007;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}
void yes(){cout << "Yes" << endl;}
void no(){cout << "No" << endl;}

int solve(){
    int n; cin >> n;
    vint a(n-1); rep(i,n-1){
        cin >> a[i];
        --a[i];
    }

    vint b(n,0);

    rep(i,n-1){
        b[a[i]]++;
    }

    rep(i,n) cout << b[i] << endl;


    return 0;
}

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


Measured memory_bytes: 4784
#include <set>
#include <map>
#include <ctime>
#include <cmath>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define PII pair<LL,LL>
#define FOR(i,a,b) for (LL i=(a);i<=(b);++i)
#define ROF(i,b,a) for (LL i=(b);i>=(a);--i)
typedef long long LL;
inline LL read(){
	LL x=0,f=1; char ch=getchar();
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}

const LL MAXN=500005;
const double eps=1e-8,INF=1e20,PI=3.141592653589793238462;
LL n,m,x,y,a,b,c,d;
int main(){
	n=read(); a=read(); b=read(); c=read(); d=read();
	x=(a>b?a-b:b-a);
	FOR(i,0,n-1)
	if ((n-1-i)%2==0){
		y=(n-1-i)/2*(d-c);
		if (c*i-y<=x&&d*i+y>=x) { printf("YES\n"); return 0; }
	}
	printf("NO\n");
	return 0;
}

/*
*/


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

int main() {
	long long ans=0;
	
	int n;
	cin >> n;
	
	int a[n]={};
	for(int i=0; i<n; i++){
		int x;
		cin >> x;
		a[x]++;
	}
	
	if(n%2==1){
		int flag=1;
		if(a[0]!=1){flag=0;}
		for(int i=1; i<n; i++){
			if(i%2==1 && a[i]!=0){
				flag=0;
			}
			if(i%2==0 && a[i]!=2){
				flag=0;
			}
		}

		if(flag==0){cout<<0<<endl;}
		else{
			ans=1;
			for(int i=0; i<n/2; i++){
				ans*=2;
				ans%=1000000007;
			}
			cout<<ans<<endl;
		}
			
	}else{
		int flag=1;
		if(a[0]!=0){flag=0;}
		for(int i=1; i<n; i++){
			if(i%2==1 && a[i]!=2){
				flag=0;
			}
			if(i%2==0 && a[i]!=0){
				flag=0;
			}
		}
		
		if(flag==0){cout<<0<<endl;}
		else{
			ans=1;
			for(int i=0; i<n/2; i++){
				ans*=2;
				ans%=1000000007;
			}
			cout<<ans<<endl;
		}		
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  ll N,K;
  cin>>N>>K;
  unordered_map<ll,ll> mp;
  for(ll i=0;i<N;i++){
    ll a,b;
    cin>>a>>b;
    mp[a]+=b;
  }
  for(ll i=1;i<=100000;i++){
    K-=mp[i];
    if(K<=0){cout<<i<<endl;return 0;}
  }
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

typedef complex<double> P;

#define EPS (1e-7)

bool operator < (P const& a, P const& b) {
  return (a.real() != a.real()) ? a.real() < b.real() : a.imag() < b.imag();
}

double dot(P const& a, P const& b) {
  return real(conj(a)*b);
}

double cross(P const& a, P const& b) {
  return imag(conj(a)*b);
}

int ccw(P a, P b, P c) {
  b -= a, c -= a;
  if(cross(b, c) > 0) return +1; // counter clockwise
  if(cross(b, c) < 0) return -1;  // clockwise
  if(dot(b, c) < 0) return +2;    // c-a-b
  if(norm(b) < norm(c)) return -2;  // a-b-c
  return 0; // on segment
}

int main () {
  
  P ps[4];
  while(1) {
    rep(i, 4) {
      cin >> ps[i].real() >> ps[i].imag();
    }
    if(cin.eof()) break;
    int sum = 0;
    rep(i, 3) {
      sum += ccw(ps[i], ps[(i+1)%3], ps[3]);
    }
    if(sum == 3 || sum == -3) cout << "YES\n";
    else cout << "NO\n";
  }
  return 0;
}

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

int main()
{
    int h, w;
    while (1)
    {
        cin >> h >> w;
        if (h == 0 && w == 0)
            break;
        rep(i, h)
        {
            rep(j, w)
            {
                if (i == 0 || i == h - 1 || j == 0 || j == w - 1)
                {
                    cout << "#";
                }
                else
                {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


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

int n;
long sum;
long a[200006];
long p[200006];

long sub(int i) {
  return sum - 2 * (p[i + n] - p[i + 1]); 
}

int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) a[i + n] = a[i];
  for (int i = 0; i < n; ++i) sum += a[i];
  p[0] = 0;
  p[1] = 0;
  for (int i = 0; i < 2 * n; ++i) {
    p[i + 2] = p[i] + a[i];
  }
  
  for (int i = 0; i < n; ++i) {
    cout << sub(i) << ' ';
  }
  cout << endl;
}

Measured memory_bytes: 4480
#include<cstdio>
#include<algorithm>


using namespace std;


int min_u(int &m, int v)
{
	if(m>v)
	{
		m=v;
		return 1;
	}
	return 0;
}


int main(void)
{
	int a, b, c, x, y;

	while(scanf("%d%d%d%d%d", &a, &b, &c, &x, &y)==5)
	{
		int ans;
		int an, bn, cn;

		an=x;bn=y;cn=0;
		ans=a*an+b*bn+c*cn;

		cn=x*2;an=0;bn=max(0, y-cn/2);
		min_u(ans, a*an+b*bn+c*cn);

		cn=y*2;bn=0;an=max(0, x-cn/2);
		min_u(ans, a*an+b*bn+c*cn);

		printf("%d\n", ans);
	}

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mp make_pair
#define ff first
#define ss second
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end()) //vector
ll n,w,wt[105],v[105];
ll k[105][100005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>w;
    for(ll i=1;i<=n;i++) cin>>wt[i]>>v[i];
    for(ll i=1;i<=n;i++)
    {
    	for(ll j=1;j<=w;j++)
    	{
    		if(wt[i]<=j) k[i][j]=max(v[i]+k[i-1][j-wt[i]],k[i-1][j]);
    		else k[i][j]=k[i-1][j];
    	}
    }
    cout<<k[n][w]<<endl;
}

Measured memory_bytes: 79360
#include<iostream>
#include<vector>
#include<string>

using ll = long long;

int main(){
    ll a, b, c, k;
    std::cin >> a >> b >> c >> k;
    ll sum = 0;
    if(k >= a){
        k -= a;
        sum += a;
        k -= b;
        if(k > 0){
            sum -= k;
        }
    }else{
        sum += k;
    }

    std::cout << sum << std::endl;
    return 0;
}


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

using namespace std;

int main(){
    int H;
    int n;
    cin >> H;
    cin >> n;
    vector<int> K;
    for(int i = 0; i < H; i++){
        int a;
        cin >> a;
        K.push_back(a);
    }
    if( K.size() <= n ){
        cout << "0" << endl;
    }
    else {
        sort(K.begin(), K.end());
        long result = 0;
        for(int i = 0; i < K.size() - n; i++){
            result += K[i];
        }
        cout << result << endl;
    }

}

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


vector<vector<int>> multiply(vector<vector<int>> A, vector<vector<int>> B)
{
	int sz = (int)A.size();

	vector<vector<int>> C(sz , vector<int>(sz,0));
	for(int i=0;i<sz;i++)
		for(int j=0;j<sz;j++)
			for(int x=0;x<sz;x++)
				C[i][j] = ( C[i][j] + A[i][x]*B[x][j] )%mod;

	return C;
}



vector<vector<int>> pow(vector<vector<int> > &adj, int n){

	if(n==1)
		return adj;

	vector<vector<int>> res = pow(adj,n/2);
	if(n&1)
		return multiply(multiply(adj,res),res); 
	else
		return multiply(res,res);

}




int32_t main(){

#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(false);
        cin.tie(NULL);

	int n,k;
	cin>>n>>k;
	vector<vector<int>> adj(n,vector<int>(n,0));
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin>>adj[i][j];


	vector<vector<int>> a = pow(adj,k);

	int ans = 0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			ans = (ans+a[i][j])%mod;
		}
	}

	cout<<ans<<endl;



}

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

int X[55], Y[55];

long double dist(long double x1, long double y1, long double x2, long double y2)
{
    return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

long double solve(long double x, long double y, int N)
{
    long double ans = 0;

    for(int i=1; i<=N; i++)
        ans = max(ans, dist(x, y, X[i], Y[i]));
    
    return ans;
}

long double func(long double x, int N)
{
    long double left = 0, right = 1000, ans;

    for(int i=1; i<=1000; i++)
    {
        long double m1 = (2 * left + right) / 3;
        long double m2 = (left + 2 * right) / 3;

        long double f1 = solve(x, m1, N);
        long double f2 = solve(x, m2, N);

        if(f1 < f2)
            right = m2, ans = f1;
        else
            left = m1, ans = f2;
    }

    return ans;
}

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

    int N;
    cin >> N;

    for(int i=1; i<=N; i++)
        cin >> X[i] >> Y[i];
    
    long double left = 0, right = 1000, ans;

    for(int i=1; i<=1000; i++)
    {
        long double m1 = (2 * left + right) / 3;
        long double m2 = (left + 2 * right) / 3;

        long double f1 = func(m1, N);
        long double f2 = func(m2, N);

        if(f1 < f2)
            right = m2, ans = f1;
        else
            left = m1, ans = f2;
    }

    cout << fixed << setprecision(12) << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
  return modpow(a, mod - 2, mod);
}

int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> vec(n);
  rep(i,n){
    cin >> vec[i];
  }
  sort(all(vec));
  ll com = 1;
  rep(i,n-k){
    com *= (i+1);
    com %= mod;
  }
  COMinit();

  // 計算例
  ll nck = COM(n, k);

  ll maxi = 0,mini = 0;
  ll bunbo = n;
  ll bunsi = k;
  rep(i,n-k+1){
    ll tmp1 = bunsi * modinv(bunbo,mod);
    tmp1 %= mod;
    mini += nck * tmp1 % mod * vec[i];
    mini %= mod;
    bunsi *= n-k-i;
    bunsi %= mod;
    bunbo *= n-i-1;
    bunbo %= mod;
  }
  sort(all(vec),greater<ll>());
  bunbo = n;
  bunsi = k;
  rep(i,n-k+1){
    ll tmp1 = bunsi * modinv(bunbo,mod);
    tmp1 %= mod;
    maxi += nck * tmp1 % mod * vec[i];
    maxi %= mod;
    bunsi *= n-k-i;
    bunsi %= mod;
    bunbo *= n-i-1;
    bunbo %= mod;
  }

  cout << (maxi - mini+mod * mod)%mod << endl;
}

Measured memory_bytes: 12928
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int h1 = Integer.parseInt(sc.next());
        int m1 = Integer.parseInt(sc.next());
        int h2 = Integer.parseInt(sc.next());
        int m2 = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int hour = h2 - h1;
        int minute = m2 - m1;
        int sumMinute = hour * 60 + minute;
        int result = sumMinute - k;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 35752
#include <iostream>
#include <queue>
using namespace std;

int main() {
  int n; cin>>n;
  bool u[50][n]; fill(u[0],u[50],false);
  queue<pair<int,int>> que;
  for(int i=1;i<=9;i++) {
    que.push({i,i%n});
    u[i][i]=true;
  }
  while(!que.empty()) {
    pair<int,int> gt = que.front(); que.pop();
    int val = gt.first, md = gt.second;
    for(int i=0;i<=9;i++) {
      if (val + i >= 50) continue;
      int md2 = (md * 10 + i) % n;
      if (!u[val+i][md2]) que.push({val+i,md2});
      u[val+i][md2] = true;
    }
  }
  int an = 51;
  for(int i=0;i<50;i++) {
    if (u[i][0])an = min(an, i);
  }
  cout<<an<<endl;
}

Measured memory_bytes: 24116