akhauriyash/Code-Regression huggingface dataset:
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include<bits/stdc++.h>
#include<chrono>
#include<unordered_map>
#include<random>
#include<complex> 
using namespace std;
typedef complex<long double> point;
#define EPS 1e-9 
#define OO 1e9
#define X real()
#define Y imag()
#define vec(a,b) ((b)-(a)) 
#define polar(r,t) ((r)*exp(point(0,(t)))) 
#define angle(v) (atan2((v).Y,(v).X)) 
#define length(v) ((long double)hypot((v).Y,(v).X)) 
#define lengthSqr(v) (dot(v,v)) 
#define dot(a,b) ((conj(a)*(b)).real()) 
#define cross(a,b) ((conj(a)*(b)).imag()) 
#define rotate(v,t) (polar(v,t)) 
#define rotateabout(v,t,a)  (rotate(vec(a,v),t)+(a)) 
#define reflect(p,m) ((conj((p)/(m)))*(m)) 
#define normalize(p) ((p)/length(p)) 
#define same(a,b) (lengthSqr(vec(a,b))<EPS) 
#define mid(a,b) (((a)+(b))/point(2,0)) 
#define perp(a) (point(-(a).Y,(a).X)) 
#define colliner pointOnLine 
enum STATE { IN, OUT, BOUNDRY };

#define ll long long
#define ld long double
#define ull unsigned ll 
#define endl '\n'
#define mk make_pair
void fast_in_out() {
	std::ios_base::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
}
int dx[] = { 0,0,-1,1,-1,1,-1,1,0 };
int dy[] = { -1,1,0,0,-1,-1,1,1,0 };
int lx[] = { 2, 2, -1, 1, -2, -2, -1, 1 };
int ly[] = { -1, 1, 2, 2, 1, -1, -2, -2 };
const ld eps = 1e-3;
const int N = 2e5 + 50, M = 4e4 + 10, mod = 1e9 + 7;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll t = gcd(a, b); return t ? (a / t * b) : 0; }
ll fact[N];
ll fast_power(ll base, ll power) {
	ll result = 1;
	while (power > 0) {

		if (power & 1) {
			result = (result * base) % mod;
		}
		base = (base * base) % mod;
		power >>= 1;
	}
	return result;
}
int main() {
	fast_in_out();
	//cout << fixed << setprecision(3);
	ll n, a, b;
	cin >> n >> a >> b;
	ll ans = fast_power(2, n);
	fact[0] = 1;
	for (int i = 1; i <= max(a, b); i++) {
		fact[i] = fact[i - 1] * i;
		fact[i] %= mod;
	}
	/*
	ncr=!n/!(n-r)
	!n/!(n-r)
	(n-r)=x
	!n/!x=!(x+1)*!(x+2)....*!(n)
	*/
	ll ansy1 = 1;
	for (int i = n - a + 1; i <= n; i++) {
		ansy1 *= i;
		ansy1 %= mod;
	}
	ansy1 *= fast_power(fact[a], mod - 2);
	ll ansy2 = 1;
	for (int i = n - b + 1; i <= n; i++) {
		ansy2 *= i;
		ansy2 %= mod;
	}
	ansy2 *= fast_power(fact[b], mod - 2);
	ansy1 += ansy2;
	ansy1 %= mod;
	ans -= ansy1;
	ans -= 1;
	if (ans < 0)ans += mod;
	cout << ans;
	return 0;


}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  int n, m;
 
  while(cin >> n >> m, (n | m)){
    int N = n+m, arr[N];
    for(int i = 0 ; i < N ; i++){
      cin >> arr[i];
    }
    sort(arr, arr+N);
 
    int max = arr[0];
    for(int i = 0 ; i < N ; i++){
      max = std::max(max, arr[i] - arr[i-1]);
    }
    cout << max << endl;
  }
 
  return 0;
}

Measured memory_bytes: 1252
#include<iostream>
using namespace std;
typedef long long ll;
ll bag_p[51],pat_p[51];
ll calc(ll lv,ll x){
//  cout << lv<<" "<<x<<" "<<bag_p[lv]<<endl;
  if(lv==0){
    return 1;
  }
  lv--;
  if(x==1){
    return 0;
  }else if(x<=bag_p[lv]+1){
    return calc(lv,x-1);
  }else if(x==bag_p[lv]+2){
    return pat_p[lv]+1;
  }else if(x<=bag_p[lv]*2+2){
    return pat_p[lv]+1+calc(lv,x-(bag_p[lv]+2));
  }else{
    return 1+pat_p[lv]*2;
  }
}
int main(){
  ll n,x,p_sum=1,b_sum=1,lv;
  cin >> n>>x;
  bag_p[0]=pat_p[0]=1;
  for(int i=1;i<=n;i++){
    p_sum = p_sum*2+1;
    b_sum = b_sum*2+3;
    pat_p[i]=p_sum;
    bag_p[i]=b_sum;
  }
  lv=n;
  cout << calc(lv,x)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    char s[5];
    cin >> s;
    map<char, int> mp;
    rep(i,4) mp[s[i]]++;
    rep(i,4) if(mp[s[i]] != 2){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            //ここから
            string s = IO.ReadLineToString();
            string ans = "Good";
            for(int i = 0; i < 3; i++)
            {
                if (s.Substring(i, 1) == s.Substring(i + 1, 1))
                {
                    ans = "Bad";
                    break;
                }
            }
            //ここまで
            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }

    class Func
    {
        long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(long a, long b) { return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }
        static public int Conbin(int n, int m) { return Factorial(n) / (Factorial(n - m) * Factorial(m)); }
        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < (long)Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    class IO
    {
        static public string ReadLineToString() { return Console.ReadLine(); }
        static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); }
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public string[] ReadLineToStringArray() { return Console.ReadLine().Split(' ').ToArray(); }
        static public int[] ReadLineToIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] ReadLineToLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<string> ReadLineToStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<int> ReadLineToIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;

int main() {
  int n, m = 0, r;
  cin >> n;
  v2i v(n);
  vector<pii> s;
  vector<unordered_set<int>> u(n);
  map<pii, int> c;
  rep(i, n-1){
    int a, b;
    cin >> a >> b;
    s.push_back({min(a-1, b-1), max(a-1, b-1)});
    v[a-1].push_back(b-1);
    v[b-1].push_back(a-1);
  }
  rep(i, n){
    if(m < v[i].size()){
      m = v[i].size();
      r = i;
    }
  }
  deque<int> d;
  d.push_back(r);
  int tmp = r, tc = 1;
  v1b ch(n, 1); ch[r] = 0;
  while(!d.empty()){
    d.pop_front();
    for(int b: v[tmp]){
      if(ch[b]){
        ch[b] = 0;
        d.push_back(b);
        while(u[tmp].count(tc)){
          ++tc;
          tc = (tc-1) % m + 1;
        }
        c[{min(tmp, b), max(tmp, b)}] = tc;
        u[tmp].insert(tc);
        u[b].insert(tc);
      }
    }
    tmp = d.front();
    tc = 1;
  }
  cout << m << endl;
  rep(i, s.size()) cout << c[s[i]] << endl;
  return 0;
}

Measured memory_bytes: 29044
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		String s = sc.next();

		out.println(s.indexOf('9') >= 0 ? "Yes" : "No");
		out.flush();
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) return true;
		else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) return false;
		}
		return true;
	}

	private byte readByte() {
		if (hasNextByte()) return buffer[ptr++];
		return -1;
	}

	private boolean isPrintableChar(byte c) {
		return '!' <= c && c <= '~';
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public int nextInt() {
		if (!hasNext()) throw new NoSuchElementException();
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}

	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}
}

Measured memory_bytes: 20564
import sys
sys.setrecursionlimit(100000000)

N, K = map(int, input().split())
prices = list(map(int, input().split()))
INF = 10000000000

memo = {}

def minPrice(n, k):
    if (n, k) in memo:
        return memo[(n, k)]
    if n < k:
        return INF
    if k == 0:
        return 0
    take = prices[n-1] + minPrice(n-1, k-1)
    skip = minPrice(n-1, k)
    ans = min(INF, take, skip)
    memo[(n, k)] = ans
    return ans

print(minPrice(N, K))

Measured memory_bytes: 46600
#include <cstdio>
#include <iostream>
using namespace std;

const int N = 1e5 + 5;

int n, m, h[N];
bool ok[N];

int read() {
    int x = 0, f = 1; char s;
    while((s = getchar()) < '0' || s > '9') if(s == '-') f = -1;
    while(s >= '0' && s <= '9') {x = (x << 1) + (x << 3) + (s ^ 48); s = getchar();}
    return x * f;
}

int main() {
    int x, y;
    n = read(), m = read();
    for(int i = 1; i <= n; ++ i) h[i] = read();
    for(int i = 1; i <= m; ++ i) {
        x = read(), y = read();
        if(h[x] == h[y]) {ok[x] = ok[y] = 1; continue;}
        if(h[x] < h[y]) swap(x, y);
        ok[y] = 1;
    }
    int ans = 0;
    for(int i = 1; i <= n; ++ i) if(! ok[i]) ++ ans;
    printf("%d\n", ans);
    return 0;
}


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

using namespace std;

int main() {


	std::ios::sync_with_stdio(false);
	std::cin.tie(0);


	int N, Y;

	int x, y, z;
	x = y = z = 0;

	int t, s = 0, j = 0;

	cin >> N >> Y;

	Y = Y / 1000;

	z = Y / 10;
	x = Y - z * 10;

	t = x + y + z;

	while (t != N) {
		if (t < N) {
			if (abs(N - t) > 3) {
				if (y > 0) {
					y--;
					x += 5;
				}
				else {
					z--;
					y += 2;
				}
			}
			else {
				if (z > 0) {
					z--;
					y += 2;
				}
				else {
					y--;
					x += 5;
				}
			}
		}
		else if (t > N) {
			if (abs(N - t) > 3) {
				if (x > 0) {
					y++;
					x -= 5;
				}
				else {
					z++;
					y -= 2;
				}
			}
			else {
				if (y > 0) {
					z++;
					y -= 2;
				}
				else {
					y++;
					x -= 5;
				}
			}
		}
		t = x + y + z;
		s++;
		if (s > 1000000 || x < 0 || y < 0 || z < 0) {
			cout << "-1 -1 -1";
			j = 1;
			break;
		}
	}


	if (j == 0) {
		cout << z << " " << y << " " << x << " ";
	}


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
using namespace std;

const double pi=4*atan(1.0);

int main() {
	int N;
	cin>>N;
	vector<int> arr(N);
	for(auto& val:arr)
		cin>>val;

	long long ans=0;
	for(int i=0;i<N;++i){
		ans+=arr[i]/2;
		if(arr[i]%2!=0){
			arr[i]%=2;
			if(i<N-1){
				if(arr[i]<=arr[i+1]){
					arr[i+1]-=arr[i];
					ans+=arr[i];
				}
				else{
					ans+=arr[i+1];
					arr[i+1]=0;
				}
			}
		}
	}

	cout<<ans<<endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
    if a[i] %2 ==0:
        if a[i] % 3 == 0:
            continue
        elif a[i] % 5== 0:
            continue
        else :
            print("DENIED")
            exit()
print("APPROVED")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  if(N%2 == 0){
    rep(i,N/2){
      if(S[i] == S[i+N/2]){
        continue;
      }
      else {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  else{
      cout << "No" << endl;
      return 0;
  }
    cout << "Yes" << endl;
    
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>

#define INF 100000000

using namespace std;

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


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;

namespace AtCoder.R167.F
{
    public static class Solver
    {
        public static void Main()
        {
            using (var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Solve(Console.In, sw);
            }
        }

        public static void Solve(TextReader tr, TextWriter tw)
        {
            WriteAnswer(tw, Parse(tr));
        }

        private static void WriteAnswer(TextWriter tw, string answer)
        {
            tw.WriteLine(answer);
        }

        private static string Parse(TextReader tr)
        {
            var n = int.Parse(tr.ReadLine());

            var s = new string[n];
            for (int i = 0; i < n; ++i)
            {
                s[i] = tr.ReadLine();
            }
            
            return Calc(s);
        }

        public static string Calc(string[] s)
        {
            var t = new (int, int)[s.Length];

            for (int i = 0; i < s.Length; ++i)
            {
                foreach (var c in s[i])
                {
                    if (c == '(')
                    {
                        ++t[i].Item2;
                    }
                    else if (c == ')')
                    {
                        t[i].Item1 = Math.Min(t[i].Item1, --t[i].Item2);
                    }
                }
            }

            if (t.Sum(x => x.Item2) != 0)
                return "No";

            var upper = t.Where(x => x.Item2 >= 0).OrderByDescending(x => x.Item1).ToArray();
            var lower = t.Where(x => x.Item2 < 0).OrderBy(x => x.Item1 - x.Item2).ToArray();

            var currentLevel = 0;

            foreach (var u in upper)
            {
                if (u.Item1 + currentLevel < 0)
                {
                    return "No";
                }
                currentLevel += u.Item2;
            }

            foreach (var u in lower)
            {
                if (u.Item1 + currentLevel < 0)
                {
                    return "No";
                }
                currentLevel += u.Item2;
            }

            return "Yes";
        }
    }
}


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

using namespace std;

string s;

int main()
{
	cin >> s;
	for (int i = 0; i < (int)s.size() - 1; i++)
	{
		if (s[i] == 'S' && s[i + 1] == 'T')
		{
			s.erase(s.begin() + i);
			s.erase(s.begin() + i);
			i -= 2;
		}
	}
	cout << s.size() << endl;
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<algorithm>
using namespace std;
int gcd(int a,int b){
	while(a){
		b%=a;
		int c=b;
		b=a;
		a=c;
	}
	return b;
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
int q[100][100];
int t[100000];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<100000;i++)t[i]=0;
		for(int i=0;i<100;i++)
			for(int j=0;j<100;j++)
				q[i][j]=0;
		for(int i=0;i<a;i++){
			int b,c;
			scanf("%d%d",&b,&c);
			for(int j=0;j<b;j++){
				int d;
				scanf("%d",&d);
				q[b][(j+b-c)%b]+=d;
			}
		}
		for(int i=0;i<55440;i++){
			for(int j=1;j<=24;j++){
				if(j==13)continue;
				if(j==17)continue;
				if(j==19)continue;
				if(j==23)continue;
				t[i]+=q[j][i%j];
			}
		}
		int f=0;
		int g=0;
		for(int i=0;i<100;i++){
			g=max(g,q[13][i]);
		}f+=g;g=0;
		for(int i=0;i<100;i++){
			g=max(g,q[17][i]);
		}f+=g;g=0;
		for(int i=0;i<100;i++){
			g=max(g,q[19][i]);
		}f+=g;g=0;
		for(int i=0;i<100;i++){
			g=max(g,q[23][i]);
		}f+=g;g=0;
		for(int i=0;i<55440;i++){
			g=max(g,t[i]);
		}
		printf("%d\n",f+g);
	}
}

Measured memory_bytes: 1436
import math

a,b,c=map(float,input().split())

if c<90:
    e=c*math.pi/180
    S=a*b*1/2*math.sin(e)
    t=a**2+b**2-2*a*b*math.cos(e)
    r=math.sqrt(t)
    L=a+b+r
    h=b*math.sin(e)
    print('{:.08f}'.format(S))
    print('{:.08f}'.format(L))
    print('{:.08f}'.format(h))

if c==90:
    e=c*math.pi/180
    S=a*b*1/2*math.sin(e)
    t=a**2+b**2-2*a*b*math.cos(e)
    r=math.sqrt(t)
    L=a+b+r
    h=b
    print('{:.08f}'.format(S))
    print('{:.08f}'.format(L))
    print('{:.08f}'.format(h))
    
if c>90:
    e=c*math.pi/180
    d=180*math.pi/180
    f=d-e
    S=a*b*1/2*math.sin(e)
    t=a**2+b**2-2*a*b*math.cos(e)
    r=math.sqrt(t)
    L=a+b+r
    h=b*math.sin(f)
    print('{:.08f}'.format(S))
    print('{:.08f}'.format(L))
    print('{:.08f}'.format(h))


Measured memory_bytes: 5716
import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.PrintWriter;
    import java.util.*;
    
    public class Main {
    
        void solve() throws IOException {
            int N = ni();
            long ans = 0;
            for (int i = 0; i < N; i++) {
                int a = ni();
                if((i+1)%2==1 && a%2==1) ans++;
            }
            out.println(ans);
        }

        final int mod = 1000000007;
        int mul(int x, int y){
            return (int)((x * 1L * y) % mod);
        }
        int add(int x, int y) {
            x += y;
            return x >= mod ? (x - mod) : x;
        }
        int sub(int x, int y){
            x = add(x,mod-y);
            return x >= mod ? (x - mod) : x;
        }
        String ns() throws IOException {
            while (!tok.hasMoreTokens()) {
                tok = new StringTokenizer(in.readLine(), " ");
            }
            return tok.nextToken();
        }
    
        int ni() throws IOException {
            return Integer.parseInt(ns());
        }
    
        long nl() throws IOException {
            return Long.parseLong(ns());
        }
    
        double nd() throws IOException {
            return Double.parseDouble(ns());
        }
    
        String[] nsa(int n) throws IOException {
            String[] res = new String[n];
            for (int i = 0; i < n; i++) {
                res[i] = ns();
            }
            return res;
        }
    
        int[] nia(int n) throws IOException {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = ni();
            }
            return res;
        }
    
        long[] nla(int n) throws IOException {
            long[] res = new long[n];
            for (int i = 0; i < n; i++) {
                res[i] = nl();
            }
            return res;
        }
    
        static BufferedReader in;
        static PrintWriter out;
        static StringTokenizer tok;
    
        public static void main(String[] args) throws IOException {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            tok = new StringTokenizer("");
            Main main = new Main();
            main.solve();
            out.close();
        }
    }

Measured memory_bytes: 32740
x,y=map(int,input().split())
if x*y>0:
    if x<y:
        print(abs(x-y))
    elif x>y:
        print(abs(x-y)+2)
elif x*y<0:
    print(abs(abs(y)-abs(x))+1)
else:
    if x<0 and y==0:
        print(abs(x))
    elif x>0 and y==0:
        print(x+1)
    elif x==0 and y<0:
        print(abs(y)+1)
    else:
        print(y)
        


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

using namespace std;



int main()
{
   int n;
   cin >> n;
   vector<int> v(n), vietos(n);
   for (int i = 0; i < n; i++)cin >> v[i];
   for(int i = 0; i < n; i++)vietos[v[i]-1]=i+1;
   for(int i = 0; i < n; i++) cout << vietos[i]<<endl;
   return 0;
}


Measured memory_bytes: 1536
#include<stdio.h>
int main(void)
{
	int n,i,flg,flg2;
	long long a,b,y,x[100000];
	scanf("%d",&n);
	flg=0;
	flg2=0;
	for(i=0;i<n;i++){
		scanf("%lld",&x[i]);
		if(x[i]==0){
			flg=1;
		}
	}
	if(flg==1){
		printf("0\n");
		// printf("zero\n");
	}
	else{ 
		y=x[0];
		for(i=1;i<n;i++){
			a=1000000000000000000/x[i];
			// printf("a=%lld\n",a);
			// printf("y=%lld\n",y);
			if(a<y){
				printf("-1\n");
				flg2=1;
				break;
			}
			else {
				y=y*x[i];
			}
		}
		if(flg2==0){
			printf("%lld\n",y);
			// printf("Y\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2464
s= input()
def dfs(i,f,sum):
    if i==3:
        if sum ==7:
            print(f+'=7')
            exit()
    else:
        dfs(i+1,f+"-"+s[i+1],sum-int(s[i+1]))
        dfs(i+1,f+"+"+s[i+1],sum+int(s[i+1]))
dfs(0,s[0],int(s[0]))

Measured memory_bytes: 38256
import qualified Data.Set as S                                                                                             
main :: IO ()                                                                                                              
main = do                                                                                                                  
  s <- S.fromList <$> getLine :: IO (S.Set Char)                                                                           
  let a = filter (\x -> fst x) . map (\x -> (,) ((not . S.member x) s) x) $ ['a'..'z']                                     
  putStrLn $ if null a                                                                                                     
             then "None"                                                                                                   
             else [snd . head $ a]

Measured memory_bytes: 4988
#include<iostream>
#include<vector>

int main(void){
    int n, m, k;
    std::cin >> n >> m >> k;
    std::vector<long long int> A(n), B(m);
    std::vector<long long int> At, Bt;

    for(int i = 0; i < n; i++){
	std::cin >> A[i];
    }
    for(int i = 0; i < m; i++){
	std::cin >> B[i];
    }

    At.push_back(0);
    int i = 1;
    while(true){
	// std::cout << "i:" << i << std::endl;
	long long int tmp = At[i-1] + A[i-1];
	if(tmp > k || i > n){
	    break;
	}
	else{
	    At.push_back(tmp);
	    // std::cout << At[i] << " ";
	}
	i++;
    }
    // std::cout << std::endl;

    Bt.push_back(0);
    i = 1;
    while(Bt[i] <= k && i <= m){
	long long int tmp = Bt[i-1] + B[i-1];
	if(tmp > k || i > m){
	    break;
	}
	else{
	    Bt.push_back(tmp);
	}
	i++;
    }

    long long int sum = 0;
    int bcnt = Bt.size() - 1;
    int ans = 0;
    for(int i = 0; i < At.size(); i++){
	sum = At[i];
	int tmp = bcnt;
	for(int j = tmp; j >= 0; j--){
	    if(Bt[j] + sum <= k){
		bcnt = j;
		break;
	    }
	}
	ans = std::max(i+bcnt, ans);
	// std::cout << "i:" << i << "bcnt: " << bcnt << "ans: " << ans << std::endl;
    }

    std::cout << ans << std::endl;



    return 0;
}


Measured memory_bytes: 10876
N, K = map(int, input().split())
S = input()

S_list = [c for c in S]
#print(S_list)

if S_list[K-1] == 'A':
  S_list[K-1] = 'a'
elif S_list[K-1] == 'B':
  S_list[K-1] = 'b'
else:
  S_list[K-1] = 'c'

print(''.join(S_list))  

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
main(){
long long i,j,k,l,n,m;
while(cin>>n){
long long x[n];
for(i=0;i<n;i++)cin>>x[i];
j=0;k=0;
for(i=0;i<n-1;i++){
    if(x[i]>=x[i+1]) j++;
    else j=0;
    if(j>k)k=j;

}
cout<<k<<endl;
} return 0;
}

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

typedef long long int ll;

ll func(ll c, ll d) {
	if (c >= 0)
		return c / d + 1;
	else
		return 0;
}

int main(void) {
	ll a, b, x;

	cin >> a >> b >> x;

	ll ans = func(b, x) - func(a - 1, x);
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
import math

def main():
    buf = input()
    buflist = list(buf.split())
    N = int(buflist[0])
    K = int(buflist[1])
    divisor = N
    dividend = 0
    for i in range(N):
        dividend += 2 ** min(0, math.floor(math.log2(i+1) - math.log2(K)))
    print(dividend / divisor)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
from itertools import permutations
h, w = map(int, input().split())
c = []
for _ in range(10):
    c.append(list(map(int, input().split())))
a = [0]*10
for _ in range(h):
    for i in map(int, input().split()):
        if i<0:
            continue
        a[i] += 1
INF = 10**10
q = list(range(10))
dist = [INF]*10
dist[1] = 0
while q:
    mi = INF
    for i in q:
        if dist[i]<mi:
            mi = dist[i]
            mi_ind = i
    node = mi_ind
    q.remove(mi_ind)
    for i in range(10):
        if dist[node]+c[i][node] < dist[i]:
            dist[i] = dist[node]+c[i][node]

ans = 0
for i in range(10):
    ans += dist[i]*a[i]
print(ans)

Measured memory_bytes: 40300
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n;
  cin>>n;
  ll cu=1;
  for(int i=sqrt(n);i>=1;i--){
    if(n%i==0){
      cu=i;
      break;
    }
  }
  ll y=n/cu;
  ll ans=0;
  while(y){
    y/=10;
    ans++;
  }
  COUT(ans);
}


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

long double calc_dist(vector<pair<int ,int>> &v,int n,vector<int> &num){
  long double ans;
  ans=0;
  for(int i=0;i<n-1;i++){
    long double tmp1,tmp2;
    tmp1=(v[num[i]].first-v[num[i+1]].first)*(v[num[i]].first-v[num[i+1]].first);
    tmp2=(v[num[i]].second-v[num[i+1]].second)*(v[num[i]].second-v[num[i+1]].second);
    ans+=sqrt(tmp1+tmp2);
  }
  return ans;
}

int main() {
  int n;
  long double ans,cnt;
  cnt=0;  
  ans=0;
  cin>>n;
  vector<int> num;
  for(int i=0;i<n;i++){
    num.push_back(i);
  }
  vector<pair<int ,int>> v;
  for(int i=0;i<n;i++){
    int tmp1,tmp2;
    cin>>tmp1>>tmp2;
    pair<int,int> p_tp=make_pair(tmp1,tmp2);
    v.push_back(p_tp);
  }
  do{
    ans+=calc_dist(v,n,num);
    cnt++;
  }while(next_permutation(num.begin(), num.end()));
  ans=ans/cnt;
  cout<<setprecision(10)<<ans<<endl;

}



Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a[8],i;
    char ch;
    for(i=1;i<14;i++){
        scanf("%d",&a[i]);
    }
    while((ch=getchar())!='\n'){
        a[0]=a[1];
        switch(ch){
            case 'E':
                a[1]=a[4];
                a[4]=a[6];
                a[6]=a[3];
                a[3]=a[0];
                break;
            case 'N':
                a[1]=a[2];
                a[2]=a[6];
                a[6]=a[5];
                a[5]=a[0];
                break;
            case 'S':
                a[1]=a[5];
                a[5]=a[6];
                a[6]=a[2];
                a[2]=a[0];
                break;
            case 'W':
                a[1]=a[3];
                a[3]=a[6];
                a[6]=a[4];
                a[4]=a[0];
                break;
        }
    }
    printf("%d\n",a[1]);
    return 0;
} 



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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; return(0);
#define IPT(v, n) REP(i_h, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

ll gcd(ll a, ll b) {
    if (a < b) {
        return gcd(b, a);
    }
    ll c = a % b;
    while (c != 0) {
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

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

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

    if (isupper(s)) {
        MSG("A")
    } else {
        MSG("a")
    }
}


Measured memory_bytes: 3644
import sys
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache, reduce
from operator import xor
INF = float("inf")
sys.setrecursionlimit(10**7)

# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]


def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W


def main():
    N = int(input())
    A = list(map(int, input().split()))

    ans = []
    a_min, a_max = min(A), max(A)
    idx = A.index(a_min) if abs(a_min) > abs(a_max) else A.index(a_max)
    for i in range(N):
        if i != idx:
            A[i] += A[idx]
            ans.append((idx, i))
    ans.append((idx, idx))

    if abs(a_min) > abs(a_max):
        for i in range(N - 1, 0, -1):
            ans.append((i, i - 1))
    else:
        for i in range(0, N - 1):
            ans.append((i, i + 1))

    print(len(ans))
    for a, b in ans:
        print(a + 1, b + 1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main() {
  int w,h,x,y,r;
  cin >> w >> h>>x>>y>>r;
  if (w>=x+r && h>=y+r && x-r>=0 && y-r>=0){
     cout << "Yes" << endl;
  }
  else {cout << "No" << endl;}

 
}


Measured memory_bytes: 3112
#include <cstdio>
#include <algorithm>
using namespace std;

const int maxn = 1e5;
char s[maxn + 1];

int main(){
  int n, k, block = 1;
  scanf("%d%d%s", &n, &k, s);
  for(int i = 1; i < n; i++)
    if(s[i] != s[i - 1]) block++;
  int ans = n - block + min(k, block / 2) * 2;
  if(ans == n) ans--;
  printf("%d", ans);
  return 0;
}


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




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


    int a[n+100],b[n+100],c[n+100];

    rep(i,n){
        cin>>a[i]>>b[i]>>c[i];
    }

    ll dp[n+5][3];
    
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for(int i=0;i<n-1;i++){
            dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a[i + 1];
            dp[i + 1][1] = max(dp[i][0], dp[i][2]) + b[i + 1];
            dp[i + 1][2] = max(dp[i][0], dp[i][1]) + c[i + 1];
    }

    cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}) << endl;
    return 0;
}

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

signed main(){
	int X, N, i;
	scanf("%d%d", &X, &N);
	vector<int> p(N);
	for(i = 0; i < N; i++){
		scanf("%d", &p[i]);
	}
	int ans = 0;
	for(int q = 0; q <= 101; q++){
		int f = 1;
		for(i = 0; i < N; i++){
			if(q == p[i]){
				f = 0;
			}
		}
		if(f == 0){
			continue;
		}
		if(abs(ans - X) > abs(q - X)){
			ans = q;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3796
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

struct Dice{
  int t, r, f;
  int top() { return t; }
  int bottom() { return 7 - t; }
  int right() { return r; }
  int left() { return 7 - r; }
  int front() { return f; }
  int back() { return 7 - f; }
  void toFront() { swap(f, t); t = 7 - t; }
  void toBack() { toFront(); toFront(); toFront(); }
  void toRight() { swap(t, r); t = 7 - t; }
  void toLeft() { toRight(); toRight(); toRight(); }
  void toClock() { swap(f, r); r = 7 - r; }
  void toConter() { toClock(); toClock(); toClock(); }
  int roll(int tt, int ff) {
    REP(i,30) {/*top??¨front???????????¨right????????????*/
      if (i % 10 == 0) toRight();
      else if (i % 10 == 5) toFront();
      else toClock();
      if (tt == t && ff == f) return r;
    }
    return 0;
  }
};

int main(){
	Dice dai1,dai2;
	int a[7],b[7];
	FOR(i,1,7) cin >> a[i];
	FOR(i,1,7) cin >> b[i];
	dai1.t = 1; dai1.f = 2; dai1.r = 3;
	dai2.t = 1; dai2.f = 2; dai2.r = 3;
	bool rst = false;
	REP(i,30) {/*top??¨front???????????¨right????????????*/
      if (i % 10 == 0) dai2.toRight();
      else if (i % 10 == 5) dai2.toFront();
      else dai2.toClock();
      if (b[dai2.t] == a[dai1.t] && b[dai2.f] == a[dai1.f]){
      	if(b[dai2.r]==a[dai1.r]&&b[dai2.bottom()]==a[dai1.bottom()]&&b[dai2.left()]==a[dai1.left()]&&b[dai2.back()]==a[dai1.back()]) rst = true;
      }
    }
    cout << (rst ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1160
N, K = map(int,input().split())
P = [int(x)-1 for x in input().split()]
C = [int(x) for x in input().split()]

def loop(s):
    value = 0
    done = set()
    while s not in done:
        done.add(s)
        s = P[s]
        value += C[s]
    return len(done), value

def f(s,K):
    ans = -10**18
    total = 0
    done = set()
    while s not in done:
        done.add(s)
        s = P[s]
        total += C[s]
        ans = max(ans,total)
        K -= 1

        if K==0:
            return ans

    lamb, value = loop(s)

    if K > 2*lamb:
        if value > 0:
            K -= lamb
            total += (K//lamb)*value
            ans = max(ans,total)
            K -= (K//lamb)*lamb
            K += lamb
    if value <= 0:
        K = min(K,lamb+5)
        


    while K > 0:
        s = P[s]
        total += C[s]
        ans = max(ans,total)
        K -= 1
    return ans

print(max([f(s,K) for s in range(N)]))

Measured memory_bytes: 189436
#include <stdio.h>
  
int main(void) {
  int n, a, b, i;
  scanf("%d%d%d", &a, &b, &n);
  //printf("start\n");
  for(i = 0; i < n; ++i) {
    int s, t, te;
    scanf("%d%d",&s, &t);
    if(t <= a || s >= b) {te = 1;}
    else {
      printf("1\n");
      return 0;
    }
  }
  printf("0\n");
  return 0;
}


Measured memory_bytes: 2688
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("x = %d\n", x);
#define debug2(x, y) printf("x = %d, y = %d\n", x, y);
#define debug3(x, y, z) printf("x = %d, y = %d, z = %d\n", x, y, z);
#define debug4(x, y, z, t) printf("x = %d, y = %d, z = %d, t = %d\n", x, y, z, t);
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

const int MAXN = 105;

int n, tot, A[MAXN];

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

    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    for (int k = 0; k < 100; k++) {
        for (int i = 0; i < n; i++) {
            if (A[i] > 0) {
                while (i < n && A[i] > 0) {
                    A[i]--;
                    i++;
                }

                tot++;
            }
        }
    }

    printf("%d\n", tot);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int m,n,k;
int main(){
	scanf( "%d%d%d", &m, &n, &k );
	for( int i = 0; i <= n; i++ )
		for( int j = 1; j <= m; j++ )
			if( m * i + n * j - 2 * i * j == k ){
				puts("Yes");
				return 0;
			}
	puts("No");
	return 0;
}

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

int main()
{
    int W;

    while ( cin >> W , W != -1 ) {
        cout << 3130 - (min(10, max(0, W - 10)) * 125 + min(10, max(0, W - 20)) * 140 + max(0, W - 30) * 160) << endl;
    }
    return ( 0 );
}



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

typedef long long ll;
 
int main(){
  int h, w;
  cin >> h >> w;
  for(int i=0; i<h+2; i++){
    if(i==0||i==h+1){
      for(int j=0; j<w+2; j++){
        cout << "#";
      }
      cout << endl;
      continue;
    }
    string s;
    cin >> s;
    cout << "#" << s << "#" << endl;
  }
  return 0;
}


Measured memory_bytes: 3600
taro = 0
hanako = 0
n = int(input())
for i in range(n):
    cards = input().split()
    if cards[0] > cards[1]:
        taro += 3
    elif cards[0] < cards[1]:
        hanako += 3
    elif cards[0] == cards[1]:
        taro += 1
        hanako += 1
print(str(taro) + ' ' + str(hanako))


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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define RREP(i,a) for(int i = a;i >= 0;i--)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = 0x3f3f3f3f;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char a, b;
    cin >> a >> b;
    if (a == 'H') {
        if (b == 'H') {
            cout << 'H' << endl;
        } else {
            cout << 'D' << endl;
        }
    } else {
        if (b == 'H') {
            cout << 'D' << endl;
        } else {
            cout << 'H' << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
import java.awt.geom.*;
public class Main {
	private void doit(){
		Scanner sc = new Scanner(System.in);
		int max = 2 * 3600;
		while(true){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			if(a < 0 && b < 0 && c < 0) break;
			int time = a * 3600 + b * 60 + c;
			int rest = max - time;
			int ansc = rest % 60;
			int ansb = rest % 3600 / 60;
			int ansa = rest / 3600;
			System.out.printf("%02d:%02d:%02d\n", ansa, ansb,ansc);
			rest = rest * 3;
			ansc = rest % 60;
			ansb = rest % 3600 / 60;
			ansa = rest / 3600;
			System.out.printf("%02d:%02d:%02d\n", ansa, ansb,ansc);
		}
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

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

int main(void){
  
  int n, k;
  cin >> n >> k;
  int count;
  int buffer = 1;
  
  while(n >= buffer){
    count++;
    buffer = buffer * k;
  }
  cout << count << endl;
  return 0;
}


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

int main() {
	int N,K;
	cin >> N >> K;
	
	long long ans=K;
	for(int i=1; i<N; i++){
		ans*=K-1;
	}
	cout<< ans << endl;
	return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()

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

  ll r;
  ll ans = 0;

  cin >> r;
  
  ans =  3*r*r;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF 999999999999999999
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
       ll n,i;
       string str;
       set <string> s;
       cin>>n;
       for(i=0;i<n;i++)
       {
           cin>>str;
           s.insert(str);
       }
       cout<<s.size()<<"\n";
   }
}

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

using namespace std;
using ll=long long ;

void solve() {
    int n, K;
    cin >> n >> K;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    K++;
    ll res = 0;
    int prefix = 0;
    for (int j = 30; j >= 0; j--) {
        int k = 1<<j;
        if (K & k) {
            ll sum = 0;
            for (int i = 0; i < n; i++) {
                int x = a[i];
                x -= x&(k-1);
                if ((prefix | x) <= prefix) sum += b[i];
            }
            res = max(res, sum);
            prefix |= k;
        }
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 1024
#define Judge_Online
#include<queue>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define N 1005
using namespace std;
int Sum[N]={0};

int main(){
    #ifdef Judge_Online
//    freopen("Input.txt","r",stdin);
    #endif
    int n, i, j, y, m, d;
    for(i=1;i<1000;i++)
        Sum[i]=Sum[i-1]+(i%3?195:200);
    scanf("%d",&n);
    while(n--){
        scanf("%d%d%d",&y,&m,&d);
        int sum = Sum[999]-Sum[y];
        sum += (20-d+1);
        if(y%3==0)
            sum += (10-m)*20;
        else{
            if(m%2==0)
                sum-=1;
            for(j=m+1;j<=10;j++){
                if(j%2==0)
                    sum+=19;
                else
                    sum+=20;
            }
        }
        printf("%d\n",sum);
    }
	return 0;
}

Measured memory_bytes: 0